python中file是什么文件格式
尤及
2020-06-12 10:37:335894浏览 · 0收藏 · 0评论
python中file是一个变量,不是一个文件格式
将open函数赋值给变量file只是为了使代码写起来更方便更美观
示例如下:
使用变量file之前:
open("ax.txt", 'a').write('1234566') open("ax.txt", 'a').close()
使用变量file之后:
file = open("ax.txt", 'a') file.write('1234566') file.close()
更多Python知识,请关注:Python自学网!!
关注公众号,随时随地在线学习
尤及
认证0级讲师