我想在 for 循环中插入一个 python 脚本(它只是打印出输入)。问题:代替将“i”作为变量——它只打印“i”,而不是“string1”、“string2”。 我试过:
for i in ['string1, string2']:
os.system("python scriptWhichPrintsInput.py i")
...
i
请您参考如下方法:
您应该使用格式或字符串连接:
os.system("python scriptWhichPrintsInput.py " + i)
或者:
os.system("python scriptWhichPrintsInput.py {}".format(i))
