1 if ‘filename‘ in kwargs:
2 txt = open(‘./test_01.html‘, ‘rb‘).read()#./test_01.html运行文件
3 encoding = chardet.detect(txt)[‘encoding‘]
4 html = open(kwargs[‘filename‘],encoding=encoding)
原文:https://www.cnblogs.com/cheng10/p/13817835.html