Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <pre><code>&gt;&gt;&gt; print 'абвгд' абвгд </code></pre> <p>When you type in some characters, your terminal decides how these characters are represented to the application. Your terminal might give the characters to the application encoded as utf-8, ISO-8859-5 or even something that only your terminal understands. Python gets these characters as some sequence of bytes. Then python prints out these bytes as they are, and your terminal interprets them in some way to display characters. Since your terminal usually interprets the bytes the same way as it encoded them before, everything is displayed like you typed it in.</p> <pre><code>&gt;&gt;&gt; u'абвгд' </code></pre> <p>Here you type in some characters that arrive at the python interpreter as a sequence of bytes, maybe encoded in some way by the terminal. With the <code>u</code> prefix python tries to convert this data to unicode. To do this correctly python has to known what encoding your terminal uses. In your case it looks like Python guesses your terminals encoding would be ASCII, but the received data doesn't match that, so you get an encoding error.</p> <p>The straight forward way to create unicode strings in an interactive session would therefore be something like this this:</p> <pre><code>&gt;&gt;&gt; us = 'абвгд'.decode('my-terminal-encoding') </code></pre> <p>In files you can also specify the encoding of the file with a special mode line:</p> <pre><code># -*- encoding: ISO-8859-5 -*- us = u'абвгд' </code></pre> <p>For other ways to set the default input encoding you can look at <code>sys.setdefaultencoding(...)</code> or <code>sys.stdin.encoding</code>.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload