我想在这里打印所有内容,但%testcase抛出错误

时间:2018-02-04 09:49:43

标签: python python-2.7

testcase = "tc2"

lists = ["1.1.1.1",'%s.tar',"admin","admin","n",None]%testcase

for i in lists:
    cmd = ("%s") %i
    print cmd

因为%testcase而引发错误 请说明如何执行它,因为我是编程新手

1 个答案:

答案 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