PHP
·
发表于 5年以前
·
阅读量:8279
# 写文件
>>> with open('new_file.txt',mode='w',encoding='utf-8') as f:
w = f.write('I love python\n It\'s so simple')
os.listdir()
['drinksbycountry.csv', 'IMDB-Movie-Data.csv', 'movietweetings', 'new_file.txt', 'test.csv', 'titanic_eda_data.csv', 'titanic_train_data.csv', 'train.csv']
>>> with open('new_file.txt',mode='r',encoding='utf-8') as f:
o = f.read()
print(o)
I love python
It's so simple