Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

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.]+)"µÄ×Ö·û´®


Ïà¹ØÎĵµ£º

PythonÀ©Õ¹ºÍǶÈë

1.PythonµÄÀ©Õ¹
PythonÀ©Õ¹ÊÇÖ¸ÔËÓÃÆäËûÓïÑÔ±àдijЩ¹¦ÄÜÄ£¿é£¬¹©Python³ÌÐòµ÷Ó㬳£ÓõÄÓÐPythonµÄCÀ©Õ¹ºÍC++À©Õ¹¡£PythonÀ©Õ¹µÄÄ¿µÄÖ÷ÒªÓÐÁ½¸ö£ºÒ»ÊÇΪÁ˹¦ÄÜÐèÒª£¬ÁíÍâÒ»¸öÔ­ÒòÊÇΪÁËÐÔÄÜÐèÒª¡£ÏÂÃæ½éÉÜÒ»ÏÂÔÚ²»ÔËÓù¤¾ßµÄÇé¿öÏ£¬ÔËÓÃCºÍC++ÓïÑÔ¶ÔPython½øÐÐÀ©Õ¹µÄ²½Öè¡£
À©Õ¹µÄµÚÒ»²½ÊÇÓÃC»òC++´´½¨Ò»¸öÔ´³ÌÐò£¬È»ºó ......

Python¿ª·¢Activex×é¼þ

PythonÇ¿µÄ¹¦ÄܾÍÔÚÓÚËüÎÞËù²»ÄÜ¡£
ʹÓÃwin32comÄ£¿é¿ª·¢window ActiveXµÄʾÀý£º£¨Èç¹ûÄ㻹ûÓÐ×°win32comÄ£¿éµÄ»°£¬Çëµ½http://python.net/crew/skippy/win32/Downloads.htmlÏÂÔØ£©¡£
# SimpleCOMServer.py
class PythonUtilities:
_public_methods_ = ['SplitString']
_reg_progid_ = "Python.Utilities"
......

ʹÓÃPythonÓïÑÔÉè¼Æ»ùÓÚHTMLµÄCÓïÑÔÓï·¨¼ÓÁÁÏÔʾ³ÌÐò

2005-2006ѧÄêµÚ1ѧÆÚ
±à Òë Ô­ Àí 
¿Î ³Ì Éè ¼Æ ±¨ ¸æ
°à¼¶   02¼Æ(¶þ)   
ѧºÅ     19     
ÐÕÃû     ÁõÏþÃ÷     
³É¼¨           
Ö¸µ¼½Ìʦ   ¬³¯»Ô   
Ò»¡¢   Éè¼ÆÄ¿µÄ
¼ÓÉî¶Ô±àÒ ......

Python sqlite3ºÍµ¥Ôª²âÊÔ

 
import os
import unittest # °üº¬µ¥Ôª²âÊÔÄ£¿é
import sqlite3 as sqlite # °üº¬sqlite3Ä£¿é
def get_db_path():
return "sqlite_testdb"
class TransactionTests(unittest.TestCase): # µ¥Ôª²âÊÔµÚÒ»²½:¡¡ÓÉTestCaseÅÉÉúÀà
def setUp(self): # µ¥Ôª²âÊÔ»·¾³ÅäÖÃ
......

pythonÖÐÎļþºÍĿ¼²Ù×÷

1£®»ñµÃµ±Ç°Â·¾¶
ÔÚPythonÖпÉÒÔʹÓÃos.getcwd()º¯Êý»ñµÃµ±Ç°µÄ·¾¶¡£ÆäÔ­ÐÍÈçÏÂËùʾ¡£
os.getcwd()
¸Ãº¯Êý²»ÐèÒª´«µÝ²ÎÊý£¬Ëü·µ»Øµ±Ç°µÄĿ¼¡£ÐèҪ˵Ã÷µÄÊÇ£¬µ±Ç°Ä¿Â¼²¢²»ÊÇÖ¸½Å±¾ËùÔÚµÄĿ¼£¬¶øÊÇËùÔËÐнű¾µÄĿ¼¡£ÀýÈ磬ÔÚPythonWinÖÐÊäÈëÈçϽű¾¡£
>>> import os
>>> print 'current director ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ