python文件处理小方法

文件打开

1 contents = open("file_name.txt","rb").read().decode("gbk").encode("utf8")
2 contents2 = open("file_name.txt","rb",encoding = "utf8").read().decode("gbk").encode("utf8")
1 def open_dict(Dict, path):
2     paths = os.path.join(path,Dict)
3     dictionary = open(paths,"rb").read().decode("utf8")
4     return(dictionary.split("\n"))

 

posted @ 2017-10-28 08:44  陈丙丁  阅读(218)  评论(0编辑  收藏  举报