testcase = "tc2"
lists = ["1.1.1.1",'%s.tar',"admin","admin","n",None]%testcase
for i in lists:
cmd = ("%s") %i
print cmd
Throws error because of %testcase Please show how to execute it because I am new in programming
You need to put %testcase
directly after '%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)
Output:
1.1.1.1
tc2.tar
admin
admin
n
None
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.