说,我已经写娄代码:蟒蛇对subprocess.Popen环路()和使用os.system()我得到类型错误:“诠释”对象不是可迭代
import os
import subprocess
for i in os.system('ls'):
print i
我有以下错误:
Traceback (most recent call last):
File "<console>", line 1, in <module>
TypeError: 'int' object is not iterable
当我尝试做相同的subprocess.Popen
for i in subprocess.Popen("ls" , shell=True).wait():
print i
我有同样的问题。如果我只做做使用os.system( 'LS')或subprocess.Popen( “LS”,壳=真).wait()
db.sqlite3 ip manage.py mysite
0
额外 '0',输出后未来是给出问题。任何方式摆脱它?
'0'是进程的返回码。这意味着它运行没有问题。 –
你期待'系统'返回,你可以迭代?调用'ls'的结果被输出到'sys.stdout'。 –
那好吧,如何摆脱错误TypeError:'int'对象不可迭代 – ilak