繁体   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