Строка трудно объединить Python с несколькими апострофами - PullRequest
0 голосов
/ 15 июня 2019

у меня есть этот текст:

@"%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command "iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin"

Я хочу создать строку с этим текстом и использовать ее в os.system (s), но я не могу ...

я стараюсь так:

s = R'%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe' + R' -NoProfile -InputFormat None -ExecutionPolicy Bypass' + R''' -Command "iex ((New-Object System.Net.WebClient).DownloadString'''+r"""('https://chocolatey.org/install.ps1'"""+'))" && SET "'+r'PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin"'

но если я проверю s в консоли Python, покажите это:

'%SystemRoot%\\System32\\WindowsPowerShell\\v1.0\\powershell.exe -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command "iex ((New-Object System.Net.WebClient).DownloadString(\'https://chocolatey.org/install.ps1\'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\\chocolatey\\bin"'

почему перед 'https://chocolatey.org/install.ps1 сравнить слэш?

если я запустил os.system (s) с косой чертой, верните мне ошибку помогите мне пожалуйста

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...