~
X
§
±
^
ISO-8859-15
?
è
±
^
5
?
¹
î
Î
Ò
Unicode
©
§
Ù
?
è
164
"
ù
¬
Ñ
Ñ
8364
£
î
Î
Ò
Unicode
é
A
?
è
¤
,
ò
Ñ
µ
# -
*
- coding: iso-8859-15 -
*
-
currency = u"C"
print ord(currency)
If your editor supports saving files as UTF-8 with a UTF-8 byte order mark (aka BOM), you can use that in-
stead of an encoding declaration. IDLE supports this capability if Options/General/Default Source
Encoding/UTF-8 is set. Notice that this signature is not understood in older Python releases (2.2 and earlier),
and also not understood by the operating system for script files with #! lines (only used on UNIX systems).
X
J
\
©
?
6
ì
|
±
UTF-8
ª
§
¿
±
UTF-8
I
P
£
aka BOM - Byte Order Mark
¤§
\
±
^
ù
5
O
?
è
(
²
"
IDLE
±
Ï
L
½
Options/General/Default Source Encoding/UTF-8
5
|
±
§
"
I
5
¿
´
Î
Python
Ø
|
±
ù
I
P
£
Python 2.2
½
@
¤§
Ó
|
±
#!
1
ö
X
Ú
Ø
¬
|
±
§
£
=
^u
UNIX
X
Ú
¤
"
By using UTF-8 (either through the signature or an encoding declaration), characters of most languages in the world
can be used simultaneously in string literals and comments. Using non-ASCII characters in identifiers is not supported.
To display all these characters properly, your editor must recognize that the file is UTF-8, and it must use a font that
supports all the characters in the file.
¦
^
UTF-8
S
è
£
Ã
Ø
´
^
I
P
´
?
è
(
²
¤§
·
±
3
i
Î
G
Ú
5
º
¥
¦
^
.
þ
Ü
©
ó
"
I
£
Î
¥
Ø
U
¦
^
ASCII
i
Î
8
"
(
w
«
¤
k
i
Î
§
\
½
3
?
6
ì
¥
ò
©
UTF-8
ª
§
¦
^
|
±
©
¥
¤
k
i
Î
i
N
"
2.2.4 The Interactive Startup File
p
ª
¸
é
Ä
©
When you use Python interactively, it is frequently handy to have some standard commands executed every time the
interpreter is started. You can do this by setting an environment variable named PYTHONSTARTUP to the name of a
file containing your start-up commands. This is similar to the ‘.profile’ feature of the UNIX shells.
¦
^
Python
)
º
ì
ÿ
§
·
U
I
3
z
g
)
º
ìé
Ä
1
·
-
"
\
±
3
©
¥
¹
\
1
·
-
§
½
¶
PYTHONSTARTUP
¸
C
þ5
½
ù
©
"
ù
a
q
u
Unix
shell
‘.profile’
©
"
This file is only read in interactive sessions, not when Python reads commands from a script, and not when ‘/dev/tty’
is given as the explicit source of commands (which otherwise behaves like an interactive session). It is executed in
the same namespace where interactive commands are executed, so that objects that it defines or imports can be used
without qualification in the interactive session. You can also change the prompts sys.ps1 and sys.ps2 in this file.
ù
©
3
p¬{
Ï
´
Ö
§
Python
l
¥
)
Ö
©
½
±
ª
à
‘/dev/tty’
Ü
·
-
K
Ø
¬
X
d
£
¦
+
§
1
é
´
?
3
p¬{
Ï
"
¤
§
)
º
ì
1
·
-
?
3
Ó
·¶
m
§
¤
±
d
§
½
Â
½
Ú
^
±
3
)
º
ì
¥
Ø
É
¦
^
"
\
±
3ù
©
¥
U
C
sys.ps1
Ú
sys.ps2
-
"
If you want to read an additional start-up file from the current directory, you can program this in the global start-
up file using code like ‘if os.path.isfile(’.pythonrc.py’): execfile(’.pythonrc.py’)’. If
you want to use the startup file in a script, you must do this explicitly in the script:
X
J
\
3
c
8
¹
¥
1
N
\
é
Ä
©
§
±
3
Û
é
Ä
©
¥
\
\
a
q
±
e
è
µ
‘if
os.path.isfile(’.pythonrc.py’): execfile(’.pythonrc.py’)’
"
X
J
\
3
,
¥
¦
^
é
Ä
©
§
7
L
3
¥
\
ù
é
µ
2.2. The Interpreter and Its Environment
)
º
ì
9
Ù
¸
9