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 ???)


Generally ...

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

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)

#or you can do this

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.