![](/img/trans.png)
[英]How do I remove the commas, quotes, and parentheses from an exported python list?
[英]How do I remove the parentheses in the python code below?
x,y,z=1,2,3
print((x,y,z) * 2)
#the outpout is (1, 2, 3, 1, 2, 3)
我如何让输出不包括 ()
有没有办法单独删除逗号?
将tuple
解包为单独的print
参数,您将得到它以空格分隔:
print(*(x,y,z) * 2)
然后,您可以使用sep
参数重新添加逗号:
print(*(x,y,z) * 2, sep=', ')
以下代码:
x,y,z=1,2,3
print(*((x,y,z) * 2))
将不带括号打印出来。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.