其他语法错误Python [英] Else Syntax Error Python
本文介绍了其他语法错误Python的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
if len(user_hash) > 0:
with open(log_file, "w") as log_f:
for name in user_hash:
log_f.write("Name:%s \n Email: %s" % (name, email)
else len(user_hash) < 0:
print "Nothing happened :("
我一直在else语句中出现语法错误,我不确定为什么它会一直产生这个错误。我在同一个def中没有任何其他语句,它仍然会出错。我该怎么办?
I keep getting a syntax error on the else statement and I am unsure why it keeps producing this error. I don't have any other else statements in the same def and it still gives error. What do I do?
推荐答案
你的log_f.write语句也缺少尾随')',这可能会让人感到困惑解析器...并且缩进看起来不正确。剪切和粘贴问题?
Your log_f.write statement is also missing a trailing ')', which is likely confusing the parser...and the indentation doesn't look right. Cut and paste problem?
这篇关于其他语法错误Python的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文