Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

pycharm: byte literal contains characters > 255

Tags:

python

pycharm

I found this inspection in Pycharm: "byte literal contains characters > 255". I tried to google it, but found nothing.

What does it mean? Why is it not OK to use such characters?

like image 959
Rong Avatar asked Nov 20 '14 00:11

Rong


People also ask

What is a byte string literal?

Byte and byte string literals A byte literal is a single ASCII character (in the U+0000 to U+007F range) or a single escape preceded by the characters U+0062 ( b ) and U+0027 (single-quote), and followed by the character U+0027 .

What is bytes literal in Python?

A bytes literal produces a new object each time it is evaluated, like list displays and unlike string literals. This is necessary because bytes literals, like lists and unlike strings, are mutable [4].


1 Answers

You're using a character that falls outside the normal ASCII range of ordinals 0 -> 255.

Put the following 2 lines at the top of your python files:

#!/usr/bin/env python
# -*- coding: utf-8 -*-

and the error should go away.

If not, email their support, or go to their forums.

like image 161
VooDooNOFX Avatar answered Oct 01 '22 17:10

VooDooNOFX