python用正则取出大写小写和汉字
# *_*coding:utf-8 *_* # @Author : zyb import re my_str = "Af123张BCde张BCf123张f12张BC3张三" my_str_upper='' my_str_lower='' my_str_int='' my_str_str='' upper_p = re.compile(r'[a-z]+') lower_p = re.compile(r'[A-Z]+') int_p = re.compile(r'\d+') str_p = re.compile(r'[\u4e00-\u9fa5]') for i in upper_p.findall(my_str): my_str_upper=my_str_upper+i for i in lower_p.findall(my_str): my_str_lower=my_str_lower+i for i in int_p.findall(my_str): my_str_int=my_str_int+i for i in str_p.findall(my_str): my_str_str=my_str_str+i print(my_str_upper,my_str_lower,my_str_int,my_str_str)