#print ("hello world!") string = 'hello world' f = open('hello.txt', 'w') #以写的方式打开文件 f.write(string) #将字符串写入到打开的文件中 f.close() #闭文件