PEP 0263 Defining Python Source Code Encodings
PEP 0263
Defining Python Source Code Encodings
Python will default to ASCII as standard encoding if no other
encoding hints are given.
To define a source code encoding, a magic comment must
be placed into the source files either as first or second
line in the file, such as:
# coding=<encoding name>
or (using formats recognized by popular editors)
#!/usr/bin/python
# -*- coding: <encoding name> -*-
or
#!/usr/bin/python
# vim: set fileencoding=<encoding name> :
More precisely, the first or second line must match the regular
expression "coding[:=]\s*([-\w.]+)". The first group of this
expression is then interpreted as encoding name.
To aid with platforms such as Windows, which add Unicode BOM
marks to the beginning of Unicode files, the UTF-8 signature
'\xef\xbb\xbf' will be interpreted as 'utf-8' encoding as well
(even if no magic encoding comment is given).
µ«ÊÇÔÚeclipse PydevÖÐÖ¸¶¨Ô´´úÂëÎļþΪutf-8¸ñʽ,eclipse²»»áÌí¼ÓBOM(»òÆäËûÔÒò),ËùÒÔ
ÒªÔÚµÚÒ»ÐлòÕßµÚ¶þÐÐÌí¼ÓÆ¥Åä"coding[:=]\s*([-\w.]+)"µÄ×Ö·û´®
Ïà¹ØÎĵµ£º
1.PythonµÄÀ©Õ¹
PythonÀ©Õ¹ÊÇÖ¸ÔËÓÃÆäËûÓïÑÔ±àдijЩ¹¦ÄÜÄ£¿é£¬¹©Python³ÌÐòµ÷Ó㬳£ÓõÄÓÐPythonµÄCÀ©Õ¹ºÍC++À©Õ¹¡£PythonÀ©Õ¹µÄÄ¿µÄÖ÷ÒªÓÐÁ½¸ö£ºÒ»ÊÇΪÁ˹¦ÄÜÐèÒª£¬ÁíÍâÒ»¸öÔÒòÊÇΪÁËÐÔÄÜÐèÒª¡£ÏÂÃæ½éÉÜÒ»ÏÂÔÚ²»ÔËÓù¤¾ßµÄÇé¿öÏ£¬ÔËÓÃCºÍC++ÓïÑÔ¶ÔPython½øÐÐÀ©Õ¹µÄ²½Öè¡£
À©Õ¹µÄµÚÒ»²½ÊÇÓÃC»òC++´´½¨Ò»¸öÔ´³ÌÐò£¬È»ºó ......
PythonǶÈëC++Ïê½â(1)--HelloWorld
À´CSDNµÄʱºò£¬¸Õ¸Õ½Ó´¥Python£¬ÄÇʱºò¶ÔPythonµÄǶÈ벿·ÖºÜ¸ÐÐËȤ£¬Ö»ÊÇһֱûÓÐʱ¼äÀ´ÅªÇåÆäÃæÉ´£¬Òò´ËҲһֱûÓÐʹÓÃǶÈëµÄ¹¦ÄÜ£¬ÁíÒ»¸öÔÒòÊÇÎÒ»¹Ã»ÓÐÕæÕýÓÃPythonд¹ýÒ»¸öÕýʽµÄÓÐÓõãµÄ¶«Î÷£¬²»¹ý£¬ÏÖÔڻعýÍ·À´¼ÌÐø¿´ÕâÒ»²¿·Ö£¬·¢ÏÖ»¹ÊÇͦ¼òµ¥µÄ¡£ÒÔÇ°Ïë°ÑÕⲿ·Ö·Òë³öÀ´£¬¿ÉÊÇÓ ......
pythonÖйúÂÛ̳ http://www.okpython.com/bbs/index.php
¿ªÔ´ÉçÇø http://sourceforge.net/
python¹ÙÍø http://www.python.org/
pythonIDE BOAhttp://boa-constructor.sourceforge.net/
pythonIDE ´óÈ«http://www.oschina.net/project/tag/120
python×é¼þhttp://py.dw ......
You are here: Home ‣ Dive Into Python 3 ‣
Difficulty level: ♦♢♢♢♢
Installing Python °²×°Python
❝ Tempora mutantur nos et mutamur in illis. (Times change, and we change with them.) ❞
— ancient Roman proverb
D ......
1£®»ñµÃµ±Ç°Â·¾¶
ÔÚPythonÖпÉÒÔʹÓÃos.getcwd()º¯Êý»ñµÃµ±Ç°µÄ·¾¶¡£ÆäÔÐÍÈçÏÂËùʾ¡£
os.getcwd()
¸Ãº¯Êý²»ÐèÒª´«µÝ²ÎÊý£¬Ëü·µ»Øµ±Ç°µÄĿ¼¡£ÐèҪ˵Ã÷µÄÊÇ£¬µ±Ç°Ä¿Â¼²¢²»ÊÇÖ¸½Å±¾ËùÔÚµÄĿ¼£¬¶øÊÇËùÔËÐнű¾µÄĿ¼¡£ÀýÈ磬ÔÚPythonWinÖÐÊäÈëÈçϽű¾¡£
>>> import os
>>> print 'current director ......