Does File exist in Python?
本问题已经有最佳答案,请猛点这里访问。
Possible Duplicate:
Pythonic way to check if a file exists?
如何使用python 2.6检查文件是否存在?
如果文件存在,运行exec redo.py。如果文件不存在,则执行文件start.py
文件为0KB,但名称为xxx100926.csv
似乎是
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | from os path import exists from __future__ import with_statement if exists('Xxx100926.csv'): from redo import main #execfile(u'C: edo.py') else: from start import main #execfile(u'C:\start.py') with open(Xxx100926.csv, 'a'): pass #and run main function main() |
您可以在
1 2 3 4 5 6 7 8 9 | from os path import exists if exists('Xxx100926.csv'): from redo import main else: from start import main #and run main function main() |