import subprocess
import sys
f = open('IPList.txt')
for line in f:
subprocess.call("nslookup", line, shell=True)
#print (line)
f.close()
以上程序不起作用。低于错误:
=============================================== =======================
PS C:\Python34> .\Python testnslookup.py
Traceback (most recent call last):
File "testnslookup.py", line 7, in <module>
subprocess.call("nslookup", line, shell=True)
File "C:\Python34\lib\subprocess.py", line 537, in call
with Popen(*popenargs, **kwargs) as p:
File "C:\Python34\lib\subprocess.py", line 767, in __init__
raise TypeError("bufsize must be an integer")
TypeError: bufsize must be an integer
=============================================== ========================
答案 0 :(得分:2)
尝试将所有call
非关键字参数放在列表中。
subprocess.call(["nslookup", line], shell=True)