贴代码:
# -*- coding: utf-8 -*- # 控制缩进tab数量 def GetTabStr(tab_num): tab_str = "" for i in xrange(0,tab_num): tab_str += " " return tab_str def BuildLine(str): script = "" # 这里的 GetTabStr() 控制整体缩进列数 script += GetTabStr(0) + str + "; " return script def Build_SetExtFlag(flagstr,flagval): script = "" script += "SetExtFlag(" + flagstr + "," + flagval + ")" return script if __name__ == '__main__': notice = "" roll_screen = "" script = "" if notice != "": script += BuildLine( GetTabStr(2) + Build_SetExtFlag("","1") print "roll_screen is not null string !"
输出错误:
File "test.py", line 28
print "roll_screen is not null string !"
^
SyntaxError: invalid syntax
一开始一直以为错误发生在提示的这一行(当时写的语句是个函数,不是像这的print这么简单,一眼就能看出没写错)
花了好多时间排除错误
最后发现,问题出在上一行:
script += BuildLine( GetTabStr(2) + Build_SetExtFlag("","1") )
最右侧少了一个“)”
感觉 Py 的错误提示,真的是太不友好了。。。。。