import os
filename = r'/home/tim/workspace/test.txt'
if os.path.exists(filename):
message = 'OK, the "%s" file exists.'
else:
message = "Sorry, I cannot find the "%s" file."
print message % filename
参考:
import os
filename = r'/home/tim/workspace/test.txt'
if os.path.exists(filename):
message = 'OK, the "%s" file exists.'
else:
message = "Sorry, I cannot find the "%s" file."
print message % filename
参考: