Issue
I am making a program where I need permission to file paths so I am using the chmod command. I get the paths from a text document. I put the paths there and organized them by rows by using the "/n" command. The problem is when I plug the variable in the string still has a /n on it. I was wondering if there was a way to have a txt document go down a line but in a way it wont interfere.
OSError: [WinError 123] The filename, directory name, or volume label syntax is incorrect: 'C:/Users/*****/Pictures/Camera Roll\n'
I have python 3.6.2 and windows 10. I am still in the early stages of learning this language.
Solution
You want to .strip()
the path before sending it to chmod:
st = 'abcd\n'
st.strip() == 'abcd' # strip() trims all whitespace
Answered By - cowbert Answer Checked By - Terry (WPSolving Volunteer)