I would like to open a file called "summary" and read information out of it to write into an output file, however I cannot open "summary"
I have tried to verify that the path exists - which works:
import os.path
print os.path.exists('/Users/alli/Documents/Summer2016/sfit4_trial/summary')
This prints out true. However when I try to do
import os
import glob
path = '/Users/alli/Documents/Summer2016/sfit4_trial/summary'
for infile in glob.glob(os.path.join(path, '*')):
file = open(infile, 'r').read()
print file
Nothing happens. I have looked through similar questions on SO and tried them all but not having any luck. All suggestions welcome. Thanks.
Have you tried?
...
path = '/Users/alli/Documents/Summer2016/sfit4_trial'
for infile in glob.glob(os.path.join(path, 'summary*')):
...
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.