Python Forum
get the content of the byte as string
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
get the content of the byte as string
#3
To convert byte strings into string use the decode() method (assuming the byte strings represent unicode strings encoded in some encoding)
>>> bx = b'p107\xff\xff\xff'
>>> sx = bx.decode('latin-1')
>>> sx
'p107ÿÿÿ'
Reply


Messages In This Thread
RE: get the content of the byte as string - by Gribouillis - Mar-02-2018, 11:54 AM
add a \ in the begining of a string - by ricardons - Mar-02-2018, 02:41 PM
add a \ in the begining of a string - by ricardons - Mar-02-2018, 02:34 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
Thumbs Up Parsing a YAML file without changing the string content..?, Flask - solved. SpongeB0B 2 2,280 Aug-05-2021, 08:02 AM
Last Post: SpongeB0B
  'utf-8' codec can't decode byte 0xe2 in position 122031: invalid continuation byte tienttt 12 11,576 Sep-18-2020, 10:10 PM
Last Post: tienttt
  'utf-8' codec can't decode byte 0xda in position 184: invalid continuation byte karkas 8 31,711 Feb-08-2020, 06:58 PM
Last Post: karkas
  First Byte of a string is missing while receiving data over TCP Socket shahrukh1987 3 4,258 Nov-20-2019, 10:34 AM
Last Post: shahrukh1987
  Byte string catenation inefficient in 3.7? RMJFlack 13 5,731 Aug-18-2019, 05:19 AM
Last Post: RMJFlack
  HELP: String of Zero's and One's to binary byte schwasskin 1 3,877 May-19-2019, 07:31 AM
Last Post: heiner55
  4 byte hex byte swap from binary file medievil 7 22,120 May-08-2018, 08:16 AM
Last Post: killerrex
  byte string Skaperen 5 3,876 Feb-04-2018, 08:58 AM
Last Post: Gribouillis
  byte string in python2 Skaperen 4 4,351 Nov-23-2017, 03:13 AM
Last Post: Skaperen
  Does Python 3.x have a built-in byte string compare function? Raptor88 2 16,422 Feb-18-2017, 10:44 AM
Last Post: Raptor88

Forum Jump:

User Panel Messages

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