![](/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.