python调用linux命令并读取返回结果

re = os.popen(cmd).read()   #读取整个返回结果为str

re = os.popen(cmd).readline()  #读取第一行结果为str

re = os.popen(cmd).readlines()  #按行读取整个返回结果为列表

cmd = "http://test:test%400%s" % name  #错误,前面不是变量的%要多加一个%

cmd = "http://test:test%%400%s" % name   #正确


版权声明:本文为u011381797原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。