f = open(‘buffer.py‘,‘w+‘)#打开文件,如果没有该文件则新建文件 f.write(data)#写入文件 f.close()#关闭文件
file1 = open(‘/usr/share/openstack-dashboard/openstack_dashboard/dashboards/project/telemetry/buffer.py‘,‘w+‘)#打开文件 a_string =file1.read()#读文件
file1 = open(‘/usr/share/openstack-dashboard/openstack_dashboard/dashboards/project/telemetry/buffer.py‘,‘w+‘)#打开文件 file1.truncate()#清空文件内容
python打开文件,python写入文件,python关闭文件,python读文件,python清空文件内容
原文:https://www.cnblogs.com/yibeimingyue/p/15235217.html