pythonÖÐpackage»úÖƵÄÁ½ÖÖʵÏÖ·½Ê½
µ±Ö´ÐÐimport
moduleʱ£¬½âÊÍÆ÷»á¸ù¾ÝÏÂÃæµÄËÑË÷·¾¶£¬ËÑË÷module1.pyÎļþ¡£
1) µ±Ç°¹¤×÷Ŀ¼
2) PYTHONPATHÖеÄĿ¼
3) Python°²×°Ä¿Â¼
(/usr/local/lib/python)
ÊÂʵÉÏ£¬Ä£¿éËÑË÷ÊÇÔÚ±£´æÔÚsys.pathÕâ¸öÈ«¾Ö±äÁ¿ÖеÄĿ¼ÁбíÖнøÐÐËÑË÷¡£
sys.path»áÔÚ½âÊÍÆ÷¿ªÊ¼Ö´ÐÐʱ±»³õʼ»¯³É°üº¬£º
1)µ±Ç°¹¤×÷Ŀ¼
2) PYTHONPATHÖеÄĿ¼
3) Python°²×°Ä¿Â¼
(/usr/local/lib/python)
packageÊÇÄ£¿éµÄ¼¯ºÏ£¬Ã¿Ò»¸öPackageµÄ¸ùĿ¼ÏÂÃ涼Ӧµ±ÓÐÒ»¸ö__init__.py
Îļþ¡£µ±½âÊÍÆ÷·¢ÏÖĿ¼ÏÂÓÐÕâ¸öÎļþʱ£¬Ëû¾Í»áÈÏΪÕâÊÇÒ»¸öPackage£¬¶ø²»ÊÇÒ»¸öÆÕͨµÄĿ¼¡£
ÎÒÃÇͨ¹ýÏÂÃæÕâÑùµÄÒ»¸öʵÀýÀ´ËµÃ÷
¼Ù¶¨ÏîÄ¿½á¹¹ÈçÏ£º
demo.py
MyPackage
---classOne.py
---classTwo.py
---__init__.py ÏÖÔÚÎÒÃÇͨ¹ýÁ½ÖÖ·½Ê½À´ÊµÏÖ°ü»úÖÆ£¬Ö÷ÒªÇø±ð¾ÍÔÚÓÚÊÇ·ñÔÚ__init__.pyÖÐдÈëÄ£¿éµ¼ÈëÓï¾ä¡£
1£¬__init__.pyÊÇÒ»¸ö¿Õ°×ÎļþµÄ·½Ê½£¬ demo.pyÄÚÈÝÈçÏ£º
from MyPackage.classOne import classOne
from MyPackage.classTwo import classTwo
if __name__ == "__main__":
c1 = classOne()
c1.printInfo()
c2 = classTwo()
c2.printInfo()
classOne.pyÄÚÈÝÈçÏ£º
class classOne:
def __init__(self):
self.name = "class one"
def printInfo(self):
print("i am class One!")
classTwo.pyÄÚÈÝÈçÏ£º
class classTwo:
def __init__(self):
self.name = "class two"
def printInfo(self):
print("i am class two!")
2,Èç¹ûÔÚ__init__.pyÖÐдÈëµ¼ÈëÄ£¿éµÄÓï¾ä£¬ÔòÉÏÊöÀý×Ó¿ÉÒÔÕâÑùÀ´×ö¡£
ÆäÖÐ__init__.py
Ïà¹ØÎĵµ£º
Íò¶ñµÄ±àÂë
С²Ë¶ÔÓÚÀÏʦÉÏÒ»½Ú½²µÄ²»ÊǺÜÃ÷°×£¬ÒòΪûÓÐÒ»±¾ÊéÊǽ«ÎļþÓëwebÒ»Æð½²Êڵģ¬Ëû¾ö¶¨×Ô¼ºÌ½¾¿Ò»ÏÂËüÃÇÖ®¼äµÄ²»Í¬£º
Ê×ÏÈ£¬Ð¡²ËÔÚCÅ̽¨ÁËÒ»¸öÎı¾Îĵµ file.txt,ÊäÈëËĸö×Ö£ºÎÒÊÇС²Ë¡£
È»ºó£¬Ð¡²ËÔÚshellÖÐÁ·Ï°ÆðÀ´£º
>>> file=open("c:\\file.txt","r")
>>> data=file.read()
>> ......
#from pp3e Chapter 9.3
#############################################################################
# popup three new window, with style
# destroy() kills one window, quit() kills all windows and app; top-level
# windows have title, icon, iconify/deiconify and protocol for wm events;
# there ......
python
ÓïÑÔ¸ÅÀÀ
python
½Å±¾¿ÉÒÔ´¦ÀíÍⲿ´«½øÀ´µÄ²ÎÊý ¼´sys.argv[]
£¬argv[]
µÄʹÓÃÓëlinux
ÏÂÏàͬ
python
±¾ÉíÊǽâÊÍÓïÑÔ£¬¿ÉÒÔ¶ÔÊäÈëµÄʽ×ÓÇóÖµ¡£python
Ö§³ÖµÄ¶ÔÏóÈçÕûÊý¶¼ÊÇÁ¢¼´Êý£¬´ËÍâËûÖ§³Ö¸´Êý£¬¼°¶ÔËÄÔòÔËËã½âÊÍ¡£
ptyhon
Ö§³Ö×Ö·û´®£¬·ÅÔÚµ¥/
Ë«ÒýºÅÄÚ£¬×Ö·û´®ÊÇÊý×飬¿ÉÒÔͨ¹ý[i: ......
½ñÌìÓöµ½ÁËÂé·³£º
ÓÃEclipse±àÒëpythonÏòsqliteÊý¾Ý¿â²åÈëÊý¾Ý×ÜÊÇÌáʾ±àÂëµÄÎÊÌ⣬ÎÒÉèÖÃÁËEclipseµÄworkspaceÓÃutf-8±àÂ뻹ÊDz»ÐÐ
µ«ÊÇÓÃEclipseдµÄ³ÌÐò±£´æÔÙÓÃIDLE´ò¿ªÈ´ÄܱàÒ룬Ææ¹ÖÁË
ÎÒ¿¼Âǵ½¿ÉÄÜÊÇÅäÖõÄÔÒò£¬ÕÒÕÒ±éÁËËùÓеÄÅäÖ㬶¼Ã»ÓÐÎÊÌ⣬°üÀ¨¹¤³ÌÎļþ
×îºóÎÒÓÃxvi32´ò¿ ......
[Ô´´]Python(pysvn)ÌáÈ¡svn°æ±¾¼ä¸Ä¶¯ÎļþÁбí
by AKara 2010.04.29 @ http://blog.csdn.net/akara @ akaras@163.com
---------------------------------------------------------------------
Ï£ÍûʵÏÖÒ»¸öÌáÈ¡Á½¸ösvn revision¼äÓб䶯(Ôö/ɾ/¸Ä)µÄÎļþµÄÁбí
µÄÃüÁîÐй¤¾ß£»¿ÉÒÔ°ïÎÒÃÇÏîÄ¿×öһЩÁ÷ ......