簡體   English   中英

如何使用python用雙引號中的逗號替換逗號

[英]How do I replace a comma with a comma in double quotes using python

我有一個行業列表,格式為Agriculture,Aquaculture,Forestry and Logging,Fishing Hunting and Trapping ,我需要它看起來像"Agriculture","Aquaculture","Forestry and Logging","Fishing Hunting and Trapping"

提前致謝

試試這個方法。

text = "Agriculture,Aquaculture,Forestry and Logging,Fishing Hunting and Trapping"
newtext = text.replace(',', '","')
newtext = '"' + newtext + '"'
print(newtext)

輸出


"Agriculture","Aquaculture","Forestry and Logging","Fishing Hunting and Trapping"

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM