Reputation: 7451
I am trying to change directories via python, but the folder name is variable (chosen from a list):
f=open('folderlist.txt')
for line in f:
pname = line
os.chdir('./P574/%s' % (pname))
Which doesn't quite work because I get the error message: "No such file or directory: './folders/folder_name2\n'"
The folder names I want are in a list called "folderlist.txt", but how do I stop python adding the '\n' at the end?
Thank you!
Upvotes: 0
Views: 166