基本输入输出 1、print函数输出数据到文件 打开一个文件供读取或写入,这个函数成功了会传回文件对象 函数的基本使用格式: file_obj=open(file,mode=“r”) file 用字符串列出欲打开的文件,mode打开文件的模式,file_obj是文件对象 file1=open("D:\python\Best1.txt",mode="w") # 如果print()函数里面包含 file=file1,是指将输出导向此对象 print("This is a nice day",file=file1