Answer the question
In order to leave comments, you need to log in
How to change backslash to slash in Python on Windows?
I have such a problem: I
upload a file from Django to the Selectel cloud, and the slashes are automatically changed to back slashes and the file goes to the root directory, and not to a specific folder.
For example:
'media/photo/2021/08/27/meow.jpg'
changed to:
'media\photo\2021\08\27\meow.jpg' did not help
s.replace('\\', '/')
s = os.path.join(path, filename)
return os.path.join(*s.split('\\'))
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