windows - Use user input as path to save file in Python 3? -


i'm writing script download file website, , i'm able save file using path entered code, if use input things don't work.

path = input("save location: ") 

from here i'll use os.path.join append file type end of path , use pycurl download file. getting user input path gives filenotfounderror, example c:/users/myname/desktop become c:usersmynamedesktop/v.mp4 after appending file type. i've tried c:\\users\\myname\\desktop c:\/users\/myname\/desktop give same thing, , ideally i'd avoid using double forward/back slashes in input since they're not user friendly.

if whatever reason need more code/all code don't hesitate ask. :)

try use https://docs.python.org/3/library/os.path.html#os.path.normpath

>>> x = input() c:/users/myname/desktop >>> os.path.normpath(os.path.join(x, 'v.mp4')) 'c:\\users\\myname\\desktop\\v.mp4' 

Comments