Я создаю программу, которая будет конвертировать файлы. Моя основная проблема заключается в том, что мне нужна моя программа для изменения рабочего каталога. У меня есть код для этого, но он продолжает говорить, что есть:Ошибка при использовании python для изменения каталогов в скрипте
OSError: [Errno 2] No such file or directory:
У вас есть идеи.
Вот мой текущий код:
if filetype == "Document":
path = raw_input("Please enter the path to the folder your file is stored in. An example path is /home/Documents/: ")
os.chdir(path)
filename = raw_input("Please enter the name of the file you would like to convert, including the filetype. e.g. test.txt:")
elif filetype == "Audio":
path = raw_input("Please enter the path to the folder your file is stored in. An example path is /home/Music/: ")
os.chdir(path)
filename = raw_input("Please enter the name of the file you would like to convert, including the filetype. e.g. test.txt:")
elif filetype == "Video":
path = raw_input("Please enter the path to the folder your file is stored in. An example path is /home/Movies/: ")
os.chdir(path)
filename = raw_input("Please enter the name of the file you would like to convert, including the filetype. e.g. test.txt:")
elif filetype == "Image":
path = raw_input("Please enter the path to the folder your file is stored in. An example path is /home/Pictures/: ")
os.chdir(path)
filename = raw_input("Please enter the name of the file you would like to convert, including the filetype. e.g. test.txt:")
Когда я вход в качестве пути:
/home/Pictures/
я получаю ошибку:
Traceback (most recent call last):
File "conversion.py", line 29, in <module>
os.chdir(path)
OSError: [Errno 2] No such file or directory: '/home/Pictures/'
Я проверил и это действительно работайте, когда я пишу это как cd/home/Pictures/it works.
Также показать образец ввода, который вы передаете сценарию? – ZdaR
@anmol_uppal Я внес изменения. – averyrc
Значит, вы используете Ubuntu? – ZdaR