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
Ïà¹ØÎĵµ£º
ÐèÒªÏÈ°²×°libxml2-devel libxslt-develÕâÁ½¸örpm°ü£¬Èç¹ûʹÓ÷ÇrootÓû§°²×°£¬¿ÉÒÔÏÂÔØlibxml2ºÍlibxsltµÄÔ´´úÂë½øÐа²×°¡£ libxml2-devel¡¢libxslt-devel×°ºÃºó£¬½âѹlxmlµÄ°ü£¬Çл»µ½Õâ¸ö°üµÄ·¾¶¡£
¼ÓÈëCFLAGS½øÐбàÒëºÍ°²×°£¬ÔÚshellÏÂÒÀ´ÎÊäÈëÈçÏÂÃüÁ CFLAGS=-I/usr/include/libxml2:/usr/include/libxslt/ ......
С°×ÊǸö΢ÈíÃÔ£¬ËûµÄżÏñÊDZȶû´óÊ壬ÔÒòµ±È»ÊǵØÇòÈ˶¼ÖªµÀÀ²¡£´ó¶þµÄʱºò£¬ËûµÄ“ê¡Ñ§¼Æ»®”ÔøÒ»¶ÈµÃ³Ñ£¬ÔÒòÊÇËû¹Ò¿ÆÌ«¶à¡£µ±È»£¬´óÈýÐÂѧÆÚ¿ªÊ¼µÄʱºò£¬Ãæ¶Ô¹«ÖÚÖÊÒÉ£¬Ð¡°×Õ¾ÔÚÒÎ×ÓÉÏ£¬Ïñ¼«ÁË¡¶´óÄÚÃÜ̽ÁãÁã·¢¡·ÀïµÄÎ÷ÃÅ´µÑ©£º“ÊÀ½çÊ׸»±È²»Ò»¶¨Óжà³öÉ«£¬ÕâÖ»²»¹ýÊÇÄãÃÇÕâЩÐǶ·ÊÐÃñÒ»ÏáÇéÔ¸µÄÏë·¨° ......
ÓÃPythonÌáÈ¡Îļþ¼ÐϵÄÌض¨À©Õ¹ÃûµÄÎļþ
²»ÖªµÀʲôʱºò£¬ÍøÏÐ×ÅûÓ㬹ÒÁ˸ölinuxµÄÊÓÆÁ½Ì³Ì£¬ÀïÃæÓкܶà¸öÎļþ¼Ð£¬ÓкܶàÎ޹صÄÎļþ¡£Õâ¶ÔÓÚÏñÎÒûÊÕ²ØÀ¬»øÎļþñ±ºÃµÄÈËÀ´Ëµ£¬¼òÖ±ÊÇ ......
[Ô´´]Python(pysvn)ÌáÈ¡svn°æ±¾¼ä¸Ä¶¯ÎļþÁбí
by AKara 2010.04.29 @ http://blog.csdn.net/akara @ akaras@163.com
---------------------------------------------------------------------
Ï£ÍûʵÏÖÒ»¸öÌáÈ¡Á½¸ösvn revision¼äÓб䶯(Ôö/ɾ/¸Ä)µÄÎļþµÄÁбí
µÄÃüÁîÐй¤¾ß£»¿ÉÒÔ°ïÎÒÃÇÏîÄ¿×öһЩÁ÷ ......