python中怎么用write函数写入文件-创新互联
这篇文章将为大家详细讲解有关python中怎么用write函数写入文件,小编觉得挺实用的,因此分享给大家做个参考,希望大家阅读完这篇文章后可以有所收获。
1、用write函数写入文件
poem = "This is a poem" dirs = '/Users/joseph/work/python/' filename = 'poem.txt' path = dirs + filename f = open(path, 'w') f.write(poem) f.close()
2、设置字体大小
实例:将字体大小更改为16(默认值为8)
import turtle as t t.write('中国', font=("Arial", 16))
关于python中怎么用write函数写入文件就分享到这里了,希望以上内容可以对大家有一定的帮助,可以学到更多知识。如果觉得文章不错,可以把它分享出去让更多的人看到。
本文标题:python中怎么用write函数写入文件-创新互联
当前地址:http://tyjierui.cn/article/hophc.html