Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8282587
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T10:25:19+00:00 2026-06-08T10:25:19+00:00

I tried to understand by myself encode and decode in Python but nothing is

  • 0

I tried to understand by myself encode and decode in Python but nothing is really clear for me.

  1. str.encode([encoding,[errors]])
  2. str.decode([encoding,[errors]])

First, I don’t understand the need of the “encoding” parameter in these two functions.

What is the output of each function, its encoding? What is the use of the “encoding” parameter in each function? I don’t really understand the definition of “bytes string”.

I have an important question, is there some way to pass from one encoding to another?
I have read some text on ASN.1 about “octet string”, so I wondered whether it was the same as “bytes string”.

Thanks for you help.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T10:25:20+00:00Added an answer on June 8, 2026 at 10:25 am

    It’s a little more complex in Python 2 (compared to Python 3), since it conflates the concepts of ‘string’ and ‘bytestring’ quite a bit, but see The Absolute Minimum Every Software Developer Absolutely, Positively Must Know About Unicode and Character Sets. Essentially, what you need to understand is that ‘string’ and ‘character’ are abstract concepts that can’t be directly represented by a computer. A bytestring is a raw stream of bytes straight from disk (or that can be written straight from disk). encode goes from abstract to concrete (you give it preferably a unicode string, and it gives you back a byte string); decode goes the opposite way.

    The encoding is the rule that says ‘a’ should be represented by the byte 0x61 and ‘α’ by the two-byte sequence 0xc0\xb1.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've tried to understand some of the posts of similar, but don't quite understand
Tried examples from 'php.net' but don't understand what's the problem. Any suggestions? <?php $_SESSION['test']
I tried to understand this line of code, but it is failed. $this->request->{self::FLAG_SHOW_CONFIG} ===
I have tried my best to understand a very similar StackOverflow question , but
I have tried a lot but not been able to understand the steps involved
I tried to write a program that uses threads, but couldn't understand the o/p.
First things first ive tried to fix this myself for hours and spent a
Edit: Obviously my first question was not really easy to understand, I hope the
I'm making a simple IRC client for myself because I really don't see the
I am tired of working this out myself , i cannot understand the way

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.