【发布时间】:2011-08-25 08:02:41
【问题描述】:
我正在编写一个小脚本,它会打印文件是否存在。
但它总是说文件不存在,即使文件确实存在。
代码:
file = exists(macinput+".py")
print file
if file == "True":
print macinput+" command not found"
elif file == "True":
print os.getcwd()
os.system("python "+macinput+".py")
print file
【问题讨论】:
-
您可能想再看看
if/elif语句。 -
将“文件”作为变量名并不是一个好主意。如果你想稍后在命名空间中打开一个文件,你会遇到问题。
标签: python windows-xp operating-system system