2018-02-07

Python文件操作
打开文件并读取内容

file1 = open(file='abc', encoding='utf8')
contents = file1.read()
print(contents)
file1.close()

file_name = 'pi'

with open('pi', 'w', encoding='utf8') as file_object:
file_object.write('hello word\n')
file_object.write('hello word\n')
file_object.write('hello word\n')

你可能感兴趣的:(2018-02-07)