糖尿病康复,内容丰富有趣,生活中的好帮手!
糖尿病康复 > python使用正则表达式删除字符串中的其它字符只保留数字和字母

python使用正则表达式删除字符串中的其它字符只保留数字和字母

时间:2020-04-26 13:22:16

相关推荐

python使用正则表达式删除字符串中的其它字符只保留数字和字母

python使用正则表达式删除字符串中的其它字符只保留数字和字母

#python使用正则表达式删除字符串中的其它字符只保留数字和字母

# Python code to demonstrate# to remove all the characters# except numbers and alphabetsimport re# initialising stringini_string = "123abcjw:, .@! eiw"# printing initial stringprint ("initial string : ", ini_string)# function to demonstrate removal of characters# which are not numbers and alphabets using reresult = re.sub([\W_]+

如果觉得《python使用正则表达式删除字符串中的其它字符只保留数字和字母》对你有帮助,请点赞、收藏,并留下你的观点哦!

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。