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

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

1£®»ñµÃµ±Ç°Â·¾¶
ÔÚPythonÖпÉÒÔʹÓÃos.getcwd()º¯Êý»ñµÃµ±Ç°µÄ·¾¶¡£ÆäÔ­ÐÍÈçÏÂËùʾ¡£
os.getcwd()
¸Ãº¯Êý²»ÐèÒª´«µÝ²ÎÊý£¬Ëü·µ»Øµ±Ç°µÄĿ¼¡£ÐèҪ˵Ã÷µÄÊÇ£¬µ±Ç°Ä¿Â¼²¢²»ÊÇÖ¸½Å±¾ËùÔÚµÄĿ¼£¬¶øÊÇËùÔËÐнű¾µÄĿ¼¡£ÀýÈ磬ÔÚPythonWinÖÐÊäÈëÈçϽű¾¡£
>>> import os
>>> print 'current directory is ',os.getcwd()
current directory is D:\Python25\Lib\site-packages\pythonwin #ÕâÀïÊÇPythonWinµÄ°²×°Ä¿Â¼
Èç¹û½«ÉÏÊöÄÚÈÝдÈëpwd.py£¬¼ÙÉèpwd.pyλÓÚE:\book\codeĿ¼£¬ÔËÐÐWindowsµÄÃüÁîÐд°¿Ú£¬½øÈëE:\bookĿ¼£¬ÊäÈëcode\pwd.py£¬Êä³öÈçÏÂËùʾ¡£
E:\book>code\pwd.py
current directory is E:\book
2£®»ñµÃĿ¼ÖеÄÄÚÈÝ
ÔÚPythonÖпÉÒÔʹÓÃos.listdir()º¯Êý»ñµÃÖ¸¶¨Ä¿Â¼ÖеÄÄÚÈÝ¡£ÆäÔ­ÐÍÈçÏÂËùʾ¡£
os.listdir(path)
Æä²ÎÊýº¬ÒåÈçÏ¡£
·     path                      Òª»ñµÃÄÚÈÝĿ¼µÄ·¾¶¡£
ÒÔÏÂʵÀý»ñµÃµ±Ç°Ä¿Â¼µÄÄÚÈÝ¡£
>>> import os
>>> os.listdir(os.getcwd())             # »ñµÃµ±Ç°Ä¿Â¼ÖеÄÄÚÈÝ
['dde.pyd', 'license.txt', 'Pythonwin.exe', 'scintilla.dll', 'win32ui.pyd', 'win32uiole.pyd', 'pywin']
3£®´´½¨Ä¿Â¼
ÔÚPythonÖпÉÒÔʹÓÃos.mkdir()º¯Êý´´½¨Ä¿Â¼¡£ÆäÔ­ÐÍÈçÏÂËùʾ¡£
os.mkdir(path)
Æä²ÎÊýº¬ÒåΪ¡£
·     path                      Òª´´½¨Ä¿Â¼µÄ·¾¶¡£
ÒÔϵÄʵÀý½«ÔÚE:\bookĿ¼Ï´´½¨tempĿ¼¡£
>>> import os
>>> os.mkdir('E:\\book\\temp')          # ʹÓÃos.mkdir´´½¨Ä¿Â¼
4£®É¾³ýĿ¼
ÔÚPythonÖпÉÒÔʹÓÃos.rmdir()º¯Êýɾ³ýĿ¼¡£ÆäÔ­ÐÍÈçÏÂËùʾ¡£
os.rmdir(path)
Æä²ÎÊýº¬ÒåÈçÏ¡£
·     path                      Ҫɾ³ýµÄĿ¼µÄ·¾¶¡£
ÒÔÏÂʵÀýɾ³ýE:\book\tempÄ¿Â


Ïà¹ØÎĵµ£º

PythonÀ©Õ¹ºÍǶÈë

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

ѧϰ¡¶PythonÓïÑÔÈëÃÅ¡·µÚʮտò¼ÜÓëÓ¦ÓÃ

¹ØÓÚ¿ò¼Ü£¬Ö®Ç°ÌýµÃ±È½Ï¶à£¬ÌرðÊÇÔÚCPyGµÄÓʼþÁбíÉÏ£¬²»¹ý»¹Ã»ÓнӴ¥¹ý¡£
ÕâÒ»ÕÂÎÒ´òËãÂÔ¶Á£¬¼ÓÉÏÕâÁ½ÌìÉíÌå²»ÊÊ£¬¶ÁµÃ¸ü¼ÓÂÔÁË¡£
ÕâÒ»ÕÂÌáµ½µÄ¼¸¸ö¿ò¼ÜÎÒÌý˵µÄÓÐTKinterºÍSWIG¡£SWIG¸ãÁËһϣ¬TKinter¿´È˼ÒÓùý£¬×Ô¼º»¹Ã»ÓÐÓùý¡£¶ÔÕâЩ¿ò¼ÜÄ°ÉúµÃºÜ¡£ÒÔºóÅöÉÏÒªÓÃÁËÔÙÈÏÕæѧѧ¡£
µ½ÏÖÔÚ£¬¶ÔPythonËãÊÇÓÐЩÁ˽âÁË¡£ ......

Python×°ÊÎÆ÷

Ô­ÎÄ£ºhttp://www.klipdas.com/blog/?p=python-decorator
python×°ÊÎÆ÷½éÉÜ
Python 2.2ÖÐÒýÈëµÄ classmethod() ºÍ staticmethod() ÄÚÖú¯Êý£¬Äã¿ÉÒÔÕâÑùµ÷ÓÃclassmethod()£º
class A:
def foo(self, y):
print y
foo = classmethod(foo)
Ò²¿ÉÒÔÕâÑù£º
class A:
@classmethod
def foo(sel ......

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 ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ