I’ve been trying to solve this problem all day. I just want to list the files within a directory that a user will specify. Below is my code and traceback:
>>> os.listdir(r'{}'.format(input('directory:')))
directory:C:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
WindowsError: [Error 123] The filename, directory name, or volume label syntax i
s incorrect: 'C:\r\\*.*'
Any help would be greatly appreciated, thank you!
You need to give
C:in string format.Its working fine for me
or try using
raw_input.If you are using
python3thanraw_inputis replaced byinput.