0
我有這樣的代碼:子,不能連接「STR」和...對象
if len(sys.argv)>1:
host = sys.argv[1]
number = sys.argv[2] if len(sys.argv)>2 else "1"
size = sys.argv[3] if len(sys.argv)>3 else "56"
timeout = sys.argv[4] if len(sys.argv)>4 else "1"
proc = subprocess.Popen(["ping \"" + host + "\" -c \"" + number + "\" -s \"" + size + "\" -W \"" + timeout + "\" 2>/dev/null | grep packets | sed 's/[^0-9,%]*//g'"], stdout=subprocess.PIPE, shell=True)
(out, err) = proc.communicate()
print "address=\"" + host + "\" data=" + out
我需要拆分出來上市。我如何實現這一目標?
一切我嘗試的原因錯誤:cannot concatenate 'str' and ... objects
就像當我嘗試:
...
res=list(out)
print "address=\"" + host + "\" data=" + res
我得到錯誤:
TypeError: cannot concatenate 'str' and 'list' objects