难以用多个撇号连接python的字符串

时间:2019-06-15 02:15:04

标签: python string concatenation

我有这段文字:

from pywinauto import Application

app = Application().connect(process = 16364)
dlg = app.top_window_()
dlg.TypeKeys('hello world')

我想用此文本创建一个字符串并在os.system中使用它,但我不能...

我这样尝试:

@"%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"

但是如果我在python控制台中检查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"'

为什么在'https://chocolatey.org/install.ps1之前比较斜杠?

如果我使用斜线运行os.system,则返回错误 请帮我

0 个答案:

没有答案