其他语法错误 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
Email: %s" % (name, email)
else len(user_hash) < 0:
print "Nothing happened :("
我不断收到有关 else 语句的语法错误,我不确定为什么它不断产生此错误.我在同一个 def 中没有任何其他 else 语句,它仍然给出错误.我该怎么办?
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屋!
查看全文