-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
  • 789
  • 3
  • 11
  • 33
philipmrz
  • 31
  • 6

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,411
  • 4
  • 16