From e1d4e4f683dd6732799c04f3d72e5810aada10c5 Mon Sep 17 00:00:00 2001 From: starnakin Date: Tue, 6 Aug 2024 12:56:44 +0200 Subject: [PATCH] fix: support utf-8 --- cast.html | 1 + main.py | 13 +++++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/cast.html b/cast.html index 5c18cc3..75b6ede 100644 --- a/cast.html +++ b/cast.html @@ -2,6 +2,7 @@ My Readings + diff --git a/main.py b/main.py index f6fff43..ec3e886 100644 --- a/main.py +++ b/main.py @@ -1,6 +1,8 @@ import json +import sys from Book import Book + # Opening JSON file f = open('constructor.json', encoding='utf-8') data = json.load(f) @@ -17,5 +19,12 @@ for book_data in books: html += book.to_html() f = open("cast.html") -print(f.read().replace("{{books}}", html).replace("{{style}}", style)) -f.close() \ No newline at end of file +text = f.read().replace("{{books}}", html).replace("{{style}}", style) +f.close() + +if len(sys.argv) > 1: + f = open(sys.argv[1], "w", encoding='utf-8') + f.write(text) + f.close() +else: + print(text) \ No newline at end of file