【问题标题】:Removing the apostrophes and join the list of strings together in python [duplicate]在python中删除撇号并将字符串列表连接在一起[重复]
【发布时间】:2023-03-06 20:19:01
【问题描述】:
"[' Food Protected from Contamination', ' Foods are adequately protected from contamination during handling and storage.', 'NA', ' Food Handler Hygiene', ' Food handler hygiene and hand washing is properly followed.', 'NA', 'Temperature & Food Storage', ' Foods are cooked, cooled and stored at proper temperatures.', 'NA', ' Garbage & Waste Handling', ' Garbage and/or waste is properly stored and removed.', 'NA', ' Pest Control', ' Pest control practices are properly maintained.', 'NA', ' Equipment & Utensil Sanitation & Storage', ' Equipment and utensils are properly cleaned, sanitized and maintained.', 'NA', ' Premise Maintenance & Sanitation', ' Food premise is properly maintained in a clean and sanitary condition.', 'NA']"

我如何修改它以使输出成为

[Food Protected from Contamination Foods are adequately protected from contamination during handling and storage. NA Food Handler Hygiene etc....]

总之,我想删除撇号

【问题讨论】:

标签: python list


【解决方案1】:

使用.join:

' '.join(YOURLIST)

【讨论】:

  • 是的,但我的当前是一个字符串,里面是一个列表。如何在应用之前先删除字符串?
  • 像这样基本的问题通常已经被问及并得到了回答。在这种情况下,推荐的做法是投票关闭/标记为重复。请不要重复回答。
猜你喜欢
  • 2021-11-24
  • 2021-12-17
  • 1970-01-01
  • 1970-01-01
  • 2015-07-07
  • 2021-12-01
  • 1970-01-01
  • 2016-07-27
  • 1970-01-01
相关资源
最近更新 更多