Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
printing a bytes string
#1
is there a quick and simple (one statement or one function/method call) to print a byte string (to stdout) without including the b' part?
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply
#2
Not sure, but may be you are looking for .encode method.
x = "This is a string"
print(x.encode('utf-8'))
Reply
#3
actually, i think i am looking for .decode() since what i have to be printed is a bytearray (several of them). i'm thinking i need to make a printb() function to do it.
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Error on import: SyntaxError: source code string cannot contain null bytes kirkwilliams2049 7 20,193 Aug-03-2023, 06:00 PM
Last Post: Gribouillis
  Printing a raw string with a folder separator at the end, duplicates the separator krulah 5 2,360 Nov-28-2022, 12:41 PM
Last Post: snippsat
  printing a string in reverse Skaperen 2 2,198 Nov-20-2021, 05:08 AM
Last Post: ghoul
  printing an string instead of a expression Underscore 2 2,590 Oct-11-2021, 03:10 PM
Last Post: deanhystad
  bytes f-string ? Skaperen 5 5,605 Jun-10-2021, 10:21 PM
Last Post: Gribouillis
  TypeError: int() argument must be a string, a bytes-like object or a number, not 'Non Anldra12 2 7,617 May-02-2021, 03:45 PM
Last Post: Anldra12
  Printing string at specific position on terminal - not showing __Mathieu__ 1 3,404 Sep-07-2020, 10:32 AM
Last Post: Larz60+
  how to do a bytes f-string? Skaperen 4 15,787 Jul-16-2020, 11:25 PM
Last Post: Skaperen
  Why, TypeError: expected string or bytes-like object ? JohnnyCoffee 3 20,731 May-08-2020, 04:26 AM
Last Post: bowlofred
  replace bytes with other byte or bytes BigOldArt 1 12,355 Feb-02-2019, 11:00 PM
Last Post: snippsat

Forum Jump:

User Panel Messages

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