python3:
f = open('print.txt', 'w') print('this is a txt', file = f) f.close()
python2:
f = open('print.txt', 'w') print>>f, 'this is a txt' f.close()
python print_txt.py > print.txt