您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

在Python中删除字符串中的引号

在Python中删除字符串中的引号

.replace()如果它们始终出现在字符串方法中,或者.strip()仅在开始和/或结束时出现,则只需使用它们:

a = '"sajdkasjdsak" "asdasdasds"'

a = a.replace('"', '')
'sajdkasjdsak asdasdasds'

# or, if they only occur at start and end...
a = a.strip('\"')
'sajdkasjdsak" "asdasdasds'

# or, if they only occur at start...
a = a.lstrip('\"')

# or, if they only occur at end...
a = a.rstrip('\"')
python 2022/1/1 18:40:29 有261人围观

撰写回答


你尚未登录,登录后可以

和开发者交流问题的细节

关注并接收问题和回答的更新提醒

参与内容的编辑和改进,让解决方法与时俱进

请先登录

推荐问题


联系我
置顶