python写的掉空格数字字母的方法
2014-02-15 17:02
501 查看
def tripNumsAlpha(): '''patt=re.compile(r"[^0-9]") then we would get like str1=''.join(re.findall(patt,"1215北京")) str1=>'北京'.Now you see what you want to . ''' import re patt=re.compile(r"[^0-9a-zA-Z]") lis1=[] with open('D:\\clrename\\clearspace.txt', 'r') as f: for it in f.readlines(): str1=''.join(re.findall(patt,it)) lis1.append(str.lstrip(str1)) f.close() with open('D:\\clrename\\clearspace-out.txt', 'w+') as f1: for it in lis1: print(it) f1.writelines(it) f1.close() print("-"*4+"Finished"+"-"*4)
相关文章推荐
- python 去除txt文本中的空格、数字、特定字母等方法
- Python判断字符串是否为字母或者数字(浮点数)的多种方法
- 利用函数统计输入字符中字母、空格、数字和其他字符个数(Python实现)
- python统计字母、空格、数字等字符个数的实例
- c语言---多种方法判断数字,字母,空格个数~
- python基础编程_13_字符串中字母、空格、数字的统计
- python统计字母、空格、数字等字符个数
- python3中计算传入字符串中单个【数字】、【字母】、【空格] 以及 【其他】的个数
- python 计算传入字符串中单个【数字】、【字母】、【空格] 以及 【其他】的个数
- python 去除txt文本中的空格、数字、特定字母等
- C++统计中英文大小写字母、数字、空格及其他字符个数的方法
- python学习:判断字符串中字母数字空格的个数
- model对象之setter方法使用,解决去除空格和将数字转成字符串展示方法
- 随机生成字母加数字16位数方法
- Python中用于检查英文字母大写的isupper()方法
- 华为oj输入一行字符,分别统计出包含英文字母、空格、数字和其他字符的个数
- 我写了一个方法,把数字转换成字母
- 深入PHP获取随机数字和字母的方法详解
- java正则表达式匹配字符串字母,数字,空格和其他字符出现次数
- python中判断字母大小写和数字字符串