首页 > 其他 > 详细

ast模块

时间:2016-12-09 16:11:51      阅读:238      评论:0      收藏:0      [点我收藏+]

有这么一个需求,你想从文件中读取字典,方法有很多,这里用的是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

  

ast模块

原文:http://www.cnblogs.com/uglyliu/p/6149752.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!