Dec-10-2017, 05:58 AM
who can help me to resolve the question,thanks 

# -*- coding:utf-8 -*- # python 3.x import re patter = [chr(i) for i in range(33,126)] with open("a.txt","r") as file: content = file.read() for i in patter: result = len(re.findall(r"[%s]" % i,content)) if result != 0: print("%s:%d" % (i, result))
Error:Traceback (most recent call last):
File "D:\robot\desk\Script\login_Discuz.py", line 13, in <module>
result = len(re.findall(r"[%s]" % i,content))
File "D:\Python\Python36-32\lib\re.py", line 222, in findall
return _compile(pattern, flags).findall(string)
File "D:\Python\Python36-32\lib\re.py", line 301, in _compile
p = sre_compile.compile(pattern, flags)
File "D:\Python\Python36-32\lib\sre_compile.py", line 562, in compile
p = sre_parse.parse(p, flags)
File "D:\Python\Python36-32\lib\sre_parse.py", line 855, in parse
p = _parse_sub(source, pattern, flags & SRE_FLAG_VERBOSE, 0)
File "D:\Python\Python36-32\lib\sre_parse.py", line 416, in _parse_sub
not nested and not items))
File "D:\Python\Python36-32\lib\sre_parse.py", line 523, in _parse
source.tell() - here)
sre_constants.error: unterminated character set at position 0