Python字符串修改

2024-04-19 05:18:05 发布

您现在位置:Python中文网/ 问答频道 /正文

我有一个python元组,其中包含如下项:

kone = ('ice_cream', 'sprinkles', 'toppings', 'nuts', 'cherries')

我正试图将该元组添加到命令行调用中,但格式设置已关闭。我当前的代码如下所示:

subprocess.popen("python", str(kone))

但我会称之为

 ('python',"('ice_cream', 'sprinkles', 'toppings', 'nuts', 'cherries')")

如何编辑代码,使其只返回“通力”中的内容:

 ('python','ice_cream', 'sprinkles', 'toppings', 'nuts', 'cherries')

Tags: 代码命令行格式元组subprocessnutspopentoppings