Python读写文件

来源:互联网 发布:通过照片搜淘宝app 编辑:程序博客网 时间:2024/06/11 04:57
#--coding:utf-8--#向指定文件中存储指定内容def text_create(name,msg):    full_path = name+ '.txt'    file = open(full_path,'w')    file.write(msg)    file.close()    #从指定文件中读取文本内容def read_text(name):    full_path = name + '.txt'    file = open(full_path,'r')    msg = file.read()    print msg    #测试text_create('hello','hello world')read_text('hello')

原创粉丝点击