13
A
回答
23
>>> numbers = 1,2
>>> print ",".join("'{0}'".format(n) for n in numbers)
'1','2'
8
32
怎麼樣?
>>> numbers=1,2
>>> numbers
(1, 2)
>>> map(str, numbers)
['1', '2']
>>> ",".join(map(str, numbers))
'1,2'
5
什麼是你的回答給?
>>> print ",".join(str(n) for n in numbers)
1,2
如果你真的想'1','2'
然後做
>>> print ",".join("'%d'" % n for n in numbers)
'1','2'
+1
我希望你不要採取這種錯誤的方式,但你有一隻可愛的雞。 – cheeken
相關問題
- 1. Xcode的整數++加入4
- 2. Python檢查整數輸入
- 3. 加入整數數組
- 4. Python RSA加密整數
- 5. 加入與Python具有整數值的列表
- 6. 加入整數中列出的名單在python
- 7. 整數輸入驗證Python的
- 8. 追加兩個整數列出「..」的Python
- 9. 加入導入的數字Python
- 10. 從輸入添加連續整數(從Python轉換到C++)
- 11. 如何在python中加入整數間隔?
- 12. 加入列表中的元素(整數)
- 13. 在Python中對整數進行舍入
- 14. 整數值錯誤Python寫入文件
- 15. Python:將整數寫入單個字節
- 16. 如何正確插入整數sqlite3 python
- 17. 將整數放入python列表中
- 18. 在Python中加入函數?
- 19. python psycopg2 copy_from()加載數據拋出錯誤的空整數值:DataError:無效輸入語法整數:「」
- 20. Python中的整數數組
- 21. Python - 輸入爲輸入到子進程的整數.Popen
- 22. 加入整數一個逗號分隔字符串的Python的方式
- 23. Python長整型輸入
- 24. 的Python:保存加入數據集---
- 25. 打印輸入整數從輸入整數到整數
- 26. 加入整數與加入字符(或變種)
- 27. 如何在Python中使用用戶輸入的整數作爲整數3
- 28. 陣列不註冊加入整數
- 29. 加入整數對象到HashSet
- 30. 用整數64鍵加入錯誤
這是不清楚。你想要輸出爲字符串還是列表/元組? – jamylak
你所描述的與「加入」不同。 –