将文本内容写到文件’/Users/luchenguang/Desktop/text.txt’中,如果文件不存在,那么新建,如果文件存在,则直接换行写入内容:helloworld a+的作用,相当于Java中的append。 ### 将文件输出到文件 fp=open('/Users/luchenguang/Desktop/text.txt','a+') print('helloworld',file=fp) fp.close()