RAM=open('/root/arg2', 'r').read()
if RAM=="":
try:
if not sys.argv[2]=="":
f = open("/root/arg2","a")
f.write(sys.argv[2])
f.close()
if float(RAM) > 4096:
os.system("echo What the hell?")
上面的脚本有什么问题?编译时,f.close()后面的行总是出错。从编译 错误:这个python脚本有什么问题?
[email protected]:~/scripts$ python -m compileall *
Compiling thatscript.py ...
Sorry: IndentationError: ('unexpected unindent', ('thatscript.py', 20, 1, '\tif float(RAM) > 4096:\n'))
我已经尝试的空间,不同的命令,新的空行。没有一个解决了它。
此错误是说,蟒蛇不知道为什么与'如果float'只缩进4个空格就行了。这就像在其他语言中使用额外的大括号。将if:块放置在与try相同的缩进级别:您将看到一个新的错误,这将帮助您一路走来。 – kevpie 2011-04-15 20:55:26