类型错误:必须是没有空字节的字符串,而不是s

2024-09-30 10:39:09 发布

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

在python中将变量传递给os.system调用时遇到问题。我有以下代码:

f1 = open("package.txt","r+")
for i in f1:
    os.system("adb shell dumpsys package %s" %i)

在我的package.txt中,我有以下内容:

^{pr2}$

我想在系统操作系统但不幸的是,我不能让它按预期工作。运行时代码会给我错误

TypeError:must be string without null bytes, not str

我看过其他关于stackoverflow的论坛/问题,他们说要在os.system调用的开头添加一个“r”,但不幸的是,这不起作用。在


Tags: 代码intxtpackageforos系统open

热门问题