Does File exist in Python? [duplicate]
Possible Duplicate:
Pythonic way to check if a file exists?
How can Check if file exist with python 2.6?
If file exists run exec redo.py. If file does not exists exec file start.py
The file is a 0kb, but name Xxx100926.csv
Ans seems to be
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()
you can put main function in redo.py
and start.py
and then
from os path import exists
if exists('Xxx100926.csv'):
from redo import main
else:
from start import main
#and run main function
main()
精彩评论