[英]How to split a string based on comma as separator with comma within double quotes remaining as it is in 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.