This is my Python code:
funcName = 'anything'
if funcName.find("Start") > 0 or funcName.find("start") > 0 or
funcName.find("Main") > 0 or funcName.find("main"):
print 'success'
else:
print 'fail'
The code output is success, but I think output must be fail.
Why is the output success?
您还需要检查最后一个find
调用 - -1
不会自动被视为错误。
if funcName.find("Start") > 0 or funcName.find("start") > 0 or funcName.find("Main") > 0 or funcName.find("main") > 0:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.