列表中要打印为 Python 中 bash 命令的一部分的元素



我有一个列表如下

list_item = [ten , hundred, thousand , million]

如何将它作为 bash 脚本的一部分打印为变量,

import os
for i in list_item()
os.system("cat  $list_item[i] >> /tmp/tmp.txt| ")

上述格式不起作用。

import os
list_item = ['ten' , 'hundred', 'thousand' , 'million']
for i in list_item:
os.system("cat " + i +" >> /tmp/tmp.txt| ")

最新更新