可能重复:
Pythonic way to check if a file exists?
如何检查python2.6中是否存在文件?
如果文件存在,请运行exec redo.py。如果文件不存在,则执行文件start.py
该文件为0kb,但名称为Xxx100926.csv。
似乎是
from os path import exists
from __future__ import with_statement
if exists('Xxx100926.csv'):
from redo import main
#execfile(u'C:\redo.py')
else:
from start import main
#execfile(u'C:\start.py')
with open(Xxx100926.csv, 'a'): pass
#and run main function
main()发布于 2010-09-27 15:39:33
您可以将主函数放在redo.py和start.py中,然后
from os path import exists
if exists('Xxx100926.csv'):
from redo import main
else:
from start import main
#and run main function
main()https://stackoverflow.com/questions/3805132
复制相似问题