# w 表示写权限,文件不存在会自动创建 fp=open('hehe.txt', 'w') a=''' 1 2 3 4 5 6 7 8 9 10 11 12 ''' # file=fp 将打开的文件赋给fp print(a,file=fp) fp.close()