python中file是什么文件格式

Python (203) 2023-07-10 18:05:53

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自学网!!

THE END

发表回复