cara mengekspor string sebagai file txt di python

text_file = open("sample.txt", "w")
n = text_file.write('Welcome to pythonexamples.org')
text_file.close()
Frantic Ferret