Python3读取txt的编码类型有很多种,不使用库如何批量读写目录下的文件?

Python3读取txt的编码类型有很多种,不使用库如何批量读写目录下的文件?

你是问题是啥呀?
编码类型?批量文件?

不需要使用库 open('file.txt', 'wb') 以字节的方式读取文件, 然后用对应的编码解码就行了

file1 = '/home/john/Downloads/20220630.txt'
file2 = '/home/john/Downloads/20220630.txt'

with open(file1, 'rb') as f:
    ms = f.readlines()
ms.decode(encoding='UTF-8')

with open(file2, 'rb') as f:
    ms = f.readlines()
ms.decode(encoding='GBK')