Python 中如何写if
python
content=str.find('ok') && content=str.find('not ok')
这样表示 在内容中找到 ok 或者 找到 not ok 对吗?
[解决办法]
并列条件用 and 而不是&&
或者条件用 or 而不是||
你的意思应该是or 你是都错了
[解决办法]
if (str.find('ok') != -1 or str.find('not ok') != -1):
print 'find'
[解决办法]
可以 be more pythonic way
>>> s = 'is it ok for ya?'
>>> if 'ok' in s:
... print 'affirmative'
...
affirmative
>>>