import os
import time
file_path="AIMP2.lnk"
if os.path.lexists(file_path):
time.sleep(1)
if os.path.isfile(file_path):
fob=open(file_path,'r');
read=fob.readlines();
for i in read:
print i
else:
print "Selected path is not file"
else:
print "File not Found "+file_path
import os.path
import time
while not os.path.exists(file_path):
time.sleep(1)
if os.path.isfile(file_path):
# read file
else:
raise ValueError("%s isn't a file!" % file_path)
每次检查之后,需要等待一定的时间