testcase = "tc2"
lists = ["1.1.1.1",'%s.tar',"admin","admin","n",None]%testcase
for i in lists:
cmd = ("%s") %i
print cmd
因为%testcase而引发错误 请说明如何执行它,因为我是编程新手
答案 0 :(得分:2)
您需要在%testcase
之后直接放置'%s.tar'
:
testcase = "tc2"
lists = ["1.1.1.1",'%s.tar' %testcase,"admin","admin","n",None]
for i in lists:
cmd = ("%s") %i
print(cmd)
输出:
1.1.1.1
tc2.tar
admin
admin
n
None