Open SoftologyPro opened 8 months ago
def writeStringToFile(text, file_path):
"""
Writes a string to a text file.
Args:
text (str): The string to be written to the file.
file_path (str): The path to the output text file.
"""
try:
with open(file_path, 'w', encoding='utf-8') as file:
file.write(text)
print(f"Text written to '{file_path}'.")
except Exception as e:
print(f"Error: {e}")
output_file_path = '/content/story.txt'
writeStringToFile(translated_text_from_text, output_file_path)
Thank you. Works fine.
What do I need to do line 3 here to save to a txt file?
Thanks.