From 212fd3188b2cceeeb55fdfb75eee28880de8c0f2 Mon Sep 17 00:00:00 2001 From: SPECT3R-69 <90955030+SPECT3R-69@users.noreply.github.com> Date: Mon, 20 Jun 2022 11:36:30 +0530 Subject: [PATCH] Fix UnicodeDecodeError - This fixes the UnicodeDecodeError issue while generating all drives list with gen_list.py file - Tidy up Co-authored-by: Levi <57452819+l3v11@users.noreply.github.com> --- gen_list.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gen_list.py b/gen_list.py index 7ee018b6..940ac1c0 100644 --- a/gen_list.py +++ b/gen_list.py @@ -31,7 +31,7 @@ subprocess.run(['rclone', 'backend', 'drives', f'{remote}'], stdout=drives) msg = '' - with open('drives.txt', 'r+') as f1: + with open('drives.txt', 'r+', encoding='utf8') as f1: lines = json.loads(f1.read()) for count, item in enumerate(lines, 1): id = item['id'] @@ -39,7 +39,7 @@ msg += f'{name} {id}\n' time.sleep(2) - with open('drive_list', 'w') as f2: + with open('drive_list', 'w', encoding='utf8') as f2: f2.truncate(0) f2.write(msg) time.sleep(2)