python delete 2 character in string

北慕城南 提交于 2021-02-17 05:41:27

问题


python search character "x" next step delete this character "x" + character "x" -1 postion in string

Example x="1. 520 2. 529"

I am going to search in x "." and delete "." and number before "." in end I want it look like x=" 520 529"

Before I created this topic I only find replace one character for one character


回答1:


import re

re.sub(r'(.\.)', '', a)

Where a is the string you want to replace in.



来源:https://stackoverflow.com/questions/43957288/python-delete-2-character-in-string

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!