Linux / pycharm / python / shorts · January 16, 2024 0

Shorts – Having issue with UTF-8 in Pycharm? Fix it below.

To fix this error, you need to declare the encoding of the source file by adding a magic comment at the top of the file. For UTF-8 encoding (which should cover Cyrillic characters) in Pycharm, the magic comment would look like this:

# -*- coding: utf-8 -*-
# Your other code below

This line should be the first or second line in your Python file.