N
N
Nodir Malikov2021-08-27 13:54:37
Python
Nodir Malikov, 2021-08-27 13:54:37

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('\\'))

didn't help either

Answer the question

In order to leave comments, you need to log in

1 answer(s)
U
U235U235, 2021-08-27
@U235U235

s.replace('/','\\')

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question