需要 import os.path 哦
有完整路径了就不需要用os.path.join(),如:
with open(r'C:\Program Files\WinRAR\ReadMe.txt', encoding='gbk') as w_stream:
result = w_stream.read()
经测试:
import os
with open(os.path.join(r'C:\Program Files\WinRAR\ReadMe.txt'), encoding='gbk') as w_stream:
result = w_stream.read()
也能读取到内容。 要么你的文本文件是空的,否则也有报错啊