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
  Printing a string containing newlines meijeru 3 69 Mar-23-2026, 03:20 AM
Last Post: deanhystad
  Error on import: SyntaxError: source code string cannot contain null bytes kirkwilliams2049 10 26,950 May-26-2025, 01:55 PM
Last Post: deanhystad
  Printing a raw string with a folder separator at the end, duplicates the separator krulah 5 3,124 Nov-28-2022, 12:41 PM
Last Post: snippsat
  printing a string in reverse Skaperen 2 2,718 Nov-20-2021, 05:08 AM
Last Post: ghoul
  printing an string instead of a expression Underscore 2 3,135 Oct-11-2021, 03:10 PM
Last Post: deanhystad
  bytes f-string ? Skaperen 5 6,554 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 8,886 May-02-2021, 03:45 PM
Last Post: Anldra12
  Printing string at specific position on terminal - not showing __Mathieu__ 1 4,141 Sep-07-2020, 10:32 AM
Last Post: Larz60+
  how to do a bytes f-string? Skaperen 4 19,099 Jul-16-2020, 11:25 PM
Last Post: Skaperen
  Why, TypeError: expected string or bytes-like object ? JohnnyCoffee 3 23,193 May-08-2020, 04:26 AM
Last Post: bowlofred

Forum Jump:

User Panel Messages

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