我是真无聊呀,不想抄作文呀写个这
import re def ret(msg): num = 0 pat = re.compile(r'[u4e00-u9fa5]+') result = pat.findall(msg) print(result) for i in result: num += len(i) return num with open('xdth.txt','r') as f: a = f.read() print(ret(a))
我是真无聊呀,不想抄作文呀写个这
import re def ret(msg): num = 0 pat = re.compile(r'[u4e00-u9fa5]+') result = pat.findall(msg) print(result) for i in result: num += len(i) return num with open('xdth.txt','r') as f: a = f.read() print(ret(a))