标签:天才 字符串替换 替换 ring tps ase python content 技术
说起来不怕人笑话,我今天才发现,python
中的字符串替换操作
,也就是 string.replace()
是可以用正则表达式
的。
之前,我的代码写法如下,粗笨:
自从发现了正则表达式
也生效后,代码变得优雅简洁:
备注:上图中的base_info
是 pandas
里的 dataframe
数据结构,可以用上述方法使用 string
的 replace
方法。
python 字符串替换功能 string.replace()可以用正则表达式,更优雅
标签:天才 字符串替换 替换 ring tps ase python content 技术
原文地址:https://www.cnblogs.com/jjliu/p/11514226.html