Python Forum
TypeError: ENCODE Method, str instead of byte
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
TypeError: ENCODE Method, str instead of byte
#2
This looks like trying to take some python2 code (where you might have needed to encode a string yourself) and run it in python3.

If python3, don't encode the string. Just pass the string to write() and it will encode it. You can pick a specific encoding at open() time, but normally you'll just use the default for your platform.
Reply


Messages In This Thread
RE: TypeError: ENCODE Method, str instead of byte - by bowlofred - May-09-2020, 06:05 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  encode/decode to show correct country letters in a CTk combobox janeik 2 732 Sep-02-2023, 09:46 AM
Last Post: janeik
Question UnicodeEncodeError: 'ascii' codec can't encode character u'\xe8' in position 562: ord ctrldan 23 4,892 Apr-24-2023, 03:40 PM
Last Post: ctrldan
  UnicodeEncodeError: 'ascii' codec can't encode character '\xfd' in position 14: ordin Armandito 6 2,746 Apr-29-2022, 12:36 PM
Last Post: Armandito
  'NoneType' object has no attribute 'encode' bhagyashree 6 8,881 Nov-05-2020, 03:50 PM
Last Post: deanhystad
  'utf-8' codec can't decode byte 0xe2 in position 122031: invalid continuation byte tienttt 12 11,618 Sep-18-2020, 10:10 PM
Last Post: tienttt
  how to encode and decode same value absolut 2 2,367 Sep-08-2020, 09:46 AM
Last Post: TomToad
  'utf-8' codec can't decode byte 0xda in position 184: invalid continuation byte karkas 8 31,741 Feb-08-2020, 06:58 PM
Last Post: karkas
  TypeError: type str doesn't define __round__ method emmapaw24 7 29,737 Feb-03-2020, 08:38 PM
Last Post: snippsat
  asyncio encode and decode, how good are they? CoderOne 2 2,354 Sep-03-2019, 11:06 PM
Last Post: wavic
  UnicodeEncodeError: 'charmap' codec can't encode character '\u2019' in position 23: c kapilan15 2 4,444 Jan-14-2019, 09:11 PM
Last Post: Gribouillis

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020