![](/img/trans.png)
[英]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.