在Windows上运行子进程会导致TypeError:必须是不带空字符的str或None,而不是s

2024-05-15 06:20:06 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试制作一个脚本来打开一个程序。我有一个命令,我通常在Windows运行时手动运行(Windows Key+R)。在

command "C:\Riot Games\League of Legends\RADS\solutions\lol_game_client_sln\releases\0.0.1.54\deploy\League of Legends.exe" "8394" "LoLLauncher.exe" "" "spectator 95.172.65.26:8088 kbbaZXzvdjwL2tHtX7XGaEG17tJQLVBa 945850509 EUN1"

import subprocess
subprocess.call('"C:\Riot Games\League of Legends\RADS\solutions\lol_game_client_sln\releases\0.0.1.53\deploy\League of Legends.exe" "8394" "LoLLauncher.exe" "" "spectator 95.172.65.26:8088 kbbaZXzvdjwL2tHtX7XGaEG17tJQLVBa 945850509 EUN1"')

当我运行这个时,我得到一个错误:

^{pr2}$

你可能已经知道我对这个很陌生,但是如果有人能帮我的话,我会非常感激的。在


Tags: ofclientgamewindowsexegamesriotdeploy
1条回答
网友
1楼 · 发布于 2024-05-15 06:20:06

"\0"是NUL字符ord('\0') == 0。这会导致你问题中的TypeError。在

使用r"\0"可以得到两个符号:反斜杠加上十进制零
list(map(ord, r'\0')) == [92, 48]。在

from subprocess import check_call

check_call([
    r"C:\Riot Games\League of Legends\RADS\solutions\lol_game_client_sln\releases\0.0.1.54\deploy\League of Legends.exe",
    "8394",
    "LoLLauncher.exe",
    "",
    "spectator 95.172.65.26:8088 kbbaZXzvdjwL2tHtX7XGaEG17tJQLVBa 945850509 EUN1"
])

注意:引号内没有引号。在

相关问题 更多 >

    热门问题