From dad7234360d7cd363f27667ebb2522610ae04be6 Mon Sep 17 00:00:00 2001 From: Mark Pilgrim Date: Fri, 11 Sep 2009 15:24:07 -0400 Subject: [PATCH] typo --- strings.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/strings.html b/strings.html index e85bdd1..a7bb7a2 100755 --- a/strings.html +++ b/strings.html @@ -366,7 +366,7 @@ TypeError: Can't convert 'bytes' object to str implicitly
  • By an amazing coincidence, this line of code says “count the occurrences of the string that you would get after decoding this sequence of bytes in this particular character encoding.” -

    And here is the link between strings and bytes: bytes objects have a decode() method that takes a character encoding and returns a string, and strings have an encode() method that takes a character encoding and returns a bytes object. In the previous example, the decoding was relatively straightforward — converting a sequence of bytes n the ASCII encoding into a string of characters. But the same process works with any encoding that supports the characters of the string — even legacy (non-Unicode) encodings. +

    And here is the link between strings and bytes: bytes objects have a decode() method that takes a character encoding and returns a string, and strings have an encode() method that takes a character encoding and returns a bytes object. In the previous example, the decoding was relatively straightforward — converting a sequence of bytes in the ASCII encoding into a string of characters. But the same process works with any encoding that supports the characters of the string — even legacy (non-Unicode) encodings.

     >>> a_string = '深入 Python'