通过子流程同时传递单引号和双引号有问题吗?

Problem with Passing both single and double quote via subprocess?

所以我想传递的原始命令是 -

runuser -l chrome -c 'DISPLAY= /opt/google/chrome-remote-desktop/start-host --code="4/yourcode" --redirect-url="https://remotedesktop.google.com/_/oauthredirect" --name=VastInstance'

我尝试了两种方法。第一个是-

def pcall(pram):
    s.run([pram], shell=True)

pcall("runuser -l raiyan -c 'DISPLAY= /opt/google/chrome-remote-desktop/start-host --code=\"4/0AY0e-g6DezhppO-9eF6BCGahZOOxN-Rs2uG0lm-G0FRIL1PvLR22-oqnCBHGmVUjr86o2A\" --redirect-url=\"https://remotedesktop.google.com/_/oauthredirect\" --name=Raiyan\'s PC' --pin=000000") ```  
      

where pcall is a function that calls subprocess.run() and the error says ```/bin/sh: 1: Syntext error: Unterminated quoted string.```

So i tried another way - ```s.run({'runuser','-l,'raiyan','-c','DISPLAY=','/opt/google/chrome-remote-desktop/start-host','--code=','4/SomeCode','--redirect-url=','https://remotedesktop.google.com/\_/oauthredirect','--name=','raiyan'])``` 

And this also show Syntex error right here
>https:// remotedesktop.google .com/\➡️_/⬅️oauthredirect 

我完全不知道在这里做什么。 [而且我也不明白为什么代码标签在这里不起作用:( ]

您可以尝试使用三引号,这样您就不必在命令中转义任何内容。

pcall("""runuser -l chrome -c 'DISPLAY= /opt/google/chrome-remote-desktop/start-host --code="4/yourcode" --redirect-url="https://remotedesktop.google.com/_/oauthredirect" --name=VastInstance'""")