I have to use:
x=input()
subprocess.Popen(f'PowerShell -Executionpolicy byPass {x}\n')
To open an executable, but it does not allow me to use a path from the input of an variable that contains backslash or spaces that are not written in the following way:
'\\'
for backslashes.'\u0020'
for spaces.
For C:\Users\Administrator\Desktop\Folder Name\executable.exe
it should look like this:
'PowerShell -Executionpolicy byPass C:\\Users\\Administrator\\Desktop\\Folder\u0020Name\\executable.exe'
How could I replace all those spaces and backslashes on the variable for those unicode equivalents? I need the user to be able just to copy and paste the executable's path.
I tried this, but didn't work:
x=input()
x=x.replace('\','\\')
x=x.replace(' ','\u0020')
I'm using Python 3.