1000字范文,内容丰富有趣,学习的好帮手!
1000字范文 > python使用正则表达式删除字符串中的其它字符只保留数字和字母

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

时间:2018-09-20 19:20:27

相关推荐

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_]+

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