有这么一个需求,你想从文件中读取字典,方法有很多,这里用的是ast模块
import ast with open("account","r",encoding="utf8") as read_file: data = ast.literal_eval(read_file.read()) print(type(data)) ##演示结果 C:\python3.5\python.exe D:/qq文件存放地/day9/FTP/测试/测试读取文件.py <class ‘dict‘> Process finished with exit code 0
时间: 2024-10-16 08:35:37