1 | initial version |
There are a few different things you can try to resolve this issue:
# -*- coding: utf-8 -*-
Replace "utf-8" with the appropriate encoding if necessary.
with open('file.txt', 'r', encoding='utf-8') as f:
# do something with the file
If the issue persists, you can try running the PowerShell command "chcp 65001" before running your Python script. This sets the code page to UTF-8.
If none of these solutions work, you may need to investigate the specific non-UTF characters causing the issue and find a way to encode or handle them appropriately.