fbpx

оператор if else

410 просмотраpython-3.6 ubuntu wsdl zeep
0
0 Комментариев

Добрый день! Столкнулся с проблемой в коде

  <span class="c1"># coding: utf8</span>
<span class="kn">from</span> <span class="nn">zeep</span> <span class="kn">import</span> <span class="n">Client</span>
<span class="k">try</span><span class="p">:</span>
    <span class="n">Number</span> <span class="o">=</span> <span class="nb">int</span> <span class="p">(</span><span class="nb">input</span><span class="p">())</span>
    <span class="n">client</span> <span class="o">=</span> <span class="n">Client</span><span class="p">(</span><span class="s1">'URL'</span><span class="p">)</span>
    <span class="n">result</span> <span class="o">=</span> <span class="n">client</span><span class="o">.</span><span class="n">service</span><span class="o">.</span><span class="n">Web</span><span class="p">(</span><span class="n">Number</span><span class="p">)</span>
<span class="k">except</span> <span class="ne">Exception</span><span class="p">:</span>
     <span class="k">print</span><span class="p">(</span><span class="s1">'Произошла ошибка'</span><span class="p">)</span>
<span class="k">else</span><span class="p">:</span>
     <span class="k">return</span><span class="p">(</span><span class="n">result</span> <span class="p">[</span><span class="s1">'return'</span><span class="p">])</span>
<span class="k">if</span> <span class="p">(</span><span class="n">result</span> <span class="o">==</span><span class="s2">"-3"</span><span class="p">)</span> <span class="ow">and</span> <span class="p">(</span><span class="n">result</span> <span class="o">==</span> <span class="s2">""</span><span class="p">){</span>
   <span class="k">print</span><span class="p">(</span><span class="s1">'Произошла ошибка'</span><span class="p">)</span>
<span class="p">}</span><span class="k">else</span><span class="p">:</span>
     <span class="k">print</span><span class="p">(</span><span class="n">result</span><span class="p">[</span><span class="s1">'return'</span><span class="p">])</span>

При вводе номера карты от сервиса получаем ее баланс, баланс может быть только положительный, но если введен не верный номер карт приходит значение -3, решил воспользоваться оператором if else, но выходит ошибка: invalid syntax


Добавить комментарий

1 Ответы

Python Опубликовано 26.04.2019
0
Denis (анонимный) 0 Comments

# coding: utf8 
from zeep import Client 
try: 
Number = int (input()) 
client = Client('URL') 
result = client.service.Web(Number) 
except Exception: 
print('Произошла ошибка') 
else: 
return(result ['return']) 
if (result =="-3") and (result == ""){ 
print('Произошла ошибка') 
}else: 
print(result['return'])

Добавить комментарий
Напишите свой ответ на данный вопрос.
Scroll Up