-1

I get this error when I try to execute my Python script on my Ubuntu 20.4 home server:

`ascii‘ codec can’t enforce character u’\u2022‘ in position 206: ordinal not in range (128)

The Amateur Coder
  • 596
  • 1
  • 8
  • 26
philipmrz
  • 21
  • 5

1 Answers1

0

You should read the Python Unicode HOWTO. This error is the first example.

Basically, you shouldn't str to convert from Unicode to encoded text/bytes.

Instead, use .encode() to encode the string:

text = 'some_str'.encode('utf-8').strip()
Guy Nachshon
  • 2,075
  • 2
  • 15