Answer the question
In order to leave comments, you need to log in
How to correctly specify relative paths to files in Python?
Very often errors get out when working with files. Here are a few of them:
os.listdir(r'png')
#FileNotFoundError: [WinError 3] Системе не удается найти указанный путь: 'png'
sftp.put(r'data.txt', r'/root/vk-ali/data.txt')
sftp.put(r'album1.txt', r'/root/vk-ali/album1.txt')
sftp.put(r'C:\Users\danis\AppData\Local\Programs\Python\Python36-32\Lib\vk_ali\desktop\posts1.txt', # ошибка
r'/root/vk-ali/posts1.txt') # ошибка
sftp.put(r'C:\Users\danis\AppData\Local\Programs\Python\Python36-32\Lib\vk_ali\desktop\posts2.txt', # ошибка
r'/root/vk-ali/posts2.txt') # ошибка
sftp.put(r'album2.txt', r'/root/vk-ali/album2.txt')
#FileNotFoundError: [WinError 2] Системе не удается найти указанный файл 'posts1.txt'
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question