在Python中从字符串中删除不需要的字符 [英] Removing unwanted characters from a string in Python
本文介绍了在Python中从字符串中删除不需要的字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一些字符串,我想从中删除一些不需要的字符.
例如:Adam'sApple ----> AdamsApple
.(不区分大小写)
有人可以帮助我吗,我需要最快的方法,因为我有几百万条记录需要完善.
谢谢
I have some strings that I want to delete some unwanted characters from them.
For example: Adam'sApple ----> AdamsApple
.(case insensitive)
Can someone help me, I need the fastest way to do it, cause I have a couple of millions of records that have to be polished.
Thanks
推荐答案
一种简单的方法:
>>> s = "Adam'sApple"
>>> x = s.replace("'", "")
>>> print x
'AdamsApple'
...或看看 regex替换
这篇关于在Python中从字符串中删除不需要的字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文