Создайте файл в определенном каталоге
# create a text file for writing
with open(r'E:\pynative\reports\profit.txt', 'w') as fp:
fp.write('This is first line')
pass
Naughty Newt