0

Are there python commands to achieve the following :

1. Create new text files

2. Write certain text to these file (similar to DOS Echo> command ???)

5
Contributors
4
Replies
5
Views
9 Years
Discussion Span
Last Post by Arrorn
0

Generally ...

text = "just a sample text"
# open the file for writing
fout = open('test.txt', 'w')
# write the text string to the file
fout.write(text)
# close the file
fout.close()
0

don't know about creating a .txt but you can write in one, read one, and several other things i normally go about writing in one similar to vegaseat:

yourface = 1
f = open('randomfile.txt', 'w')
write = ' if you have integers in your code you want to write in you do this: ' + repr(yourface)
f.write(write)

#or you can do this

f.write('meow/n')
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.