Ben Keshet wrote:
Use os.path.join
import os
folders = ['1A2B', '1A6W', '56Y7']
for x in folders:
f = open(os.path.jo in('my/path/way', x, 'my_file.txt'), 'r')
Hi fans,
>
I want to use a 'for' iteration to manipulate files in a set of folders,
something like:
>
folders= ['1A28','1A6W',' 56Y7']
for x in folders:
print x # print the current folder
f = open('my/path/way/x/my_file.txt', 'r')
...
>
>
I want to use a 'for' iteration to manipulate files in a set of folders,
something like:
>
folders= ['1A28','1A6W',' 56Y7']
for x in folders:
print x # print the current folder
f = open('my/path/way/x/my_file.txt', 'r')
...
>
import os
folders = ['1A2B', '1A6W', '56Y7']
for x in folders:
f = open(os.path.jo in('my/path/way', x, 'my_file.txt'), 'r')