how to save to file in python
with open('data.txt', 'w') as my_data_file: my_data_file.write(WhateverYourInputIs) # After leaving the above block of code, the file is closed # "w" overwrites the contents of the file
how to save to file in python
with open('data.txt', 'w') as my_data_file: my_data_file.write(WhateverYourInputIs) # After leaving the above block of code, the file is closed # "w" overwrites the contents of the file
python save input to text file
#Simple Mood Diary Script As An Example# print('My Mood Diary') mood = input('How are you feeling today? ') #Saves the input as the variable 'mood'# text_file = open("MoodDiary.txt", "w") #Opens or creates the .txt file, sharing the directory of the script# text_file.write(mood) #Writes the variable into the .txt file# text_file.close() #Closes the .txt file#
save python output to text file
$ python my_program.py > output.txt
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us