Pythonѧϰ֮OS¿â
OS¿âÌṩÁËʹÓø÷ÖÖ²Ù×÷ϵͳ¹¦ÄܵĽӿڡ£
os.name ·µ»Øµ±Ç°²Ù×÷ϵͳÃû£¬¶¨ÒåÁË'posix'£¬'nt'£¬'mac'£¬'os2'£¬'ce'£¬'java'£¨ÎÒʹÓÃwin7/python3.1,Êä³öµÄÊÇnt¡£posix²»ÖªµÀÊÇʲôϵͳ£¬macÓ¦¸ÃÊÇApple»ú°É£¬os2Ò²²»ÖªµÀÊÇʲô¶«¶«£¬ceÓ¦¸ÃÊÇwinCE°É£¬ÕâÑùµÄ»°£¬pythonÓ¦¸ÃÖ§³ÖÏòCEÒÆÖ²°¡£¬Å¼×Ô¼ºÊÔ¹ý£¬Ã»±àÒë³É¹¦£¬java¹À¼ÆÊÇSun¿ª·¢µÄÄǸösolari*ϵͳ£©
os.environ ·µ»ØÒ»¸ömapping object°üÀ¨µ±Ç°ÏµÍ³¼°Óû§µÄ»·¾³±äÁ¿£¬¸ñʽΪenviron({±äÁ¿Ãû: ±äÁ¿Öµ, ±äÁ¿Ãû: ±äÁ¿Öµ……})¡£Ê¹ÓÃos.environ[±äÁ¿Ãû]¿ÉÒÔÖ±½ÓµÃµ½ÏàÓ¦±äÁ¿Öµ£»Ò²¿ÉÒÔʹÓÃos.getenv(±äÁ¿Ãû)À´»ñµÃ±äÁ¿Öµ¡£ËµÃ÷£ºµ±import osºó£¬»·¾³±äÁ¿¼´±»Ó³É䣬Èç¹ûÔÚ´ËÆڼ䣬ÓÃÆäËü·½ÃæÐ޸Ļ·¾³£¨ÏµÍ³¼°Óû§£©£¬os.environÖµ²»»á¸Ä±ä£¬³ý·ÇÖ±½ÓÐÞ¸Äos.environµÄÖµ¡£»¹ÓÐÒ»¸öº¯Êýputenv(key, value).
os.getcwd() ·µ»Øµ±Ç°¹¤×÷Ŀ¼¡£ÀàËÆÓÚlinuxÖеÄpwdÃüÁî
os.chdir( path ) ¸Ä±äµ±Ç°¹¤×÷Ŀ¼ÖÁpath
os.fchdir( fd ) ²»ÖªµÀÓÃ;Ó÷¨¡££¨ÎÒµÄϵͳÖÐûÓÐÕâ¸öº¯Êý£©
os.ctermid() Return the filename corresponding to the controlling terminal of the process.
os.getegid() ·µ»Øµ±Ç°½ø³Ì(process)ËùÊôµÄÓÐЧgroup id Ö»ÓÐunix¿ÉÓÃ
os.geteuid() ·µ»Øµ±Ç°½ø³ÌËùÊôµÄÓû§ID (Unix)
os.getgid() ·µ»Øµ±Ç°½ø³ÌËùÊôµÄÕæʵ×éID(real group id)
os.getgroups() Return list of supplemental group ids associated with the current process.
Availability: Unix.
os.getlogin() ·µ»Øµ±Ç°µÇ½Óû§Ãû
os.getpgid( pid ) Return the process group id of the process with process id pid. If
pid is 0, the process group id of the current process is returned.
Availability: Unix.
os.getpgrp() ·µ»Øµ±Ç°½ø³Ì×éµÄID(Unix)
os.getpid() ·µ»Øµ±Ç°½ø³ÌµÄPID£¬( Unix, Windows )
os.getppid() ·µ»Øµ±Ç°½ø³Ì¸¸½ø³ÌµÄID(Unix)
os.getuid() ·µ»Øµ±Ç°½ø³ÌËùÊôÓû§ID(Unix)
os.getenv( varname[, value] ) Èç¹û´æÔÚÔò·µ»ØÏàÓ¦»·¾³±äÁ¿Öµ£¬·ñÔò·µ»ØNone
os.putenv( varname, value ) É趨һ¸ö»·¾³±äÁ¿£¬ÆäֵΪvalue¡£Ëù×÷µÄ¸Ä±ä»áÓ°Ïìµ½ÓÉos.system(), popen(),fork(), execv()µÈÆô¶¯µÄ×Ó½ø³Ì¡£(Unix, Windows)ÔÚһЩƽ̨ÈçFreeBSD, Mac OS XÉÏÉ趨»·¾³±äÁ¿¿ÉÄÜÒýÆðÄÚ´æй©¡£Èç¹ûϵͳ֧³Öputenv()º¯Êý£¬Ê¹ÓÃos.environÉèÖû·¾³±äÁ¿»á×Ô¶¯Í¨¹ýµ÷ÓÃputenv()º¯ÊýʵÏÖÏàÓ¦¹
Ïà¹ØÎĵµ£º
ʹÓà Python ·ÖÀëÖÐÎÄÓëÓ¢ÎĵĻìºÏ×Ö´®
LiYanrui
posted @ ´óÔ¼ 1 ÄêÇ°
in ³ÌÐòÉè¼Æ
with tags
python
, 614 ÔĶÁ
Õâ¸öÎÊÌâÊÇ×ö MkIV Ô¤´¦Àí³ÌÐò
ʱ¸ã¶¨µÄ£¬¾ÍÊÇ°ÑÒ»¸ö»ìºÏÁËÖÐÓ¢ÎÄ»ìºÏ×Ö´®·ÖÀëΪӢÎÄÓëÖÐÎĵÄ×Ó×Ö´®£¬Æ©È磬½« ”ÎÒµÄ English ѧµÄ²»ºÃ
&ld ......
from http://blog.alexa-pro.cn/?p=189
1: os.listdir(path) //pathΪĿ¼
¹¦ÄÜÏ൱ÓÚÔÚpathĿ¼ÏÂÖ´ÐÐdirÃüÁ·µ»ØΪlistÀàÐÍ
print os.listdir('..')
Êä³ö£º
[a,b,c,d]
2: os.path.walk(path,visit,arg)
path £ºÊǽ«Òª±éÀúµÄĿ¼
visit £ºÊÇÒ»¸öº¯ÊýÖ¸Õ룬º¯ÊýÔ²ÐÎΪ£º
callback(arg,dir,fileList)
ÆäÖÐargΪΠ......
ÔÚ»ùÓÚ»¥ÁªÍøµÄÓ¦ÓÃÖУ¬³ÌÐò¾³£ÐèÒª×Ô¶¯µØ·¢Ë͵ç×ÓÓʼþ¡£È磺һ¸öÍøÕ¾µÄ×¢²áϵͳ»áÔÚÓû§×¢²áʱ·¢ËÍÒ»·âÓʼþÀ´È·ÈÏ×¢²á£»µ±Óû§Íü¼ÇµÇ½ÃÜÂëµÄʱºò£¬Í¨¹ýÓʼþÀ´È¡»ØÃÜÂë¡£smtplibÄ£¿éÊÇpythonÖÐsmtp(¼òµ¥Óʼþ´«ÊäÐÒé)µÄ¿Í»§¶ËʵÏÖ¡£ÎÒÃÇ¿ÉÒÔʹÓÃsmtplibÄ£¿é£¬ÇáËɵķ¢Ë͵ç×ÓÓʼþ¡£ÏÂÃæµÄÀý×ÓÓÃÁ˲»µ½Ê®ÐдúÂëÀ´·¢Ë͵ç×ÓÓÊ ......
python 2.4ÖÐdatetimeÓÐstrftime·½·¨¶øÎÞstrptime·½·¨
¶øpython2.5ÖÐÕâÁ½¸ö·½·¨¾ùÓУ¬¶øÎҵĿª·¢»·¾³ÕýºÃÊÇpython 2.5£¬¶øÔËÐл·¾³ÔòÊÇpython 2.4
¿ª·¢»·¾³Ïµ÷ÊԺõijÌÐò£¬ÔÚ·þÎñÆ÷ÉϾͲ»run¡£²éÁËÒ»ÏÂpythonµÄ¹Ù·½Îĵµ
£¬Ð±Ìåд×Å£ºNew
in version 2.5.
²»¼æÈݵĴúÂëÈçÏ£º
PythonÓïÑÔ
:
test_strptime.py
res ......
from link http://www.tt010.net/cms/show_article/1057.html
·¢±íÆÀÂÛ
Post by : BossAdmin @[2009-12-12 17:11:20] views:115
adodb£ºÎÒÃÇÁìµ¼ÍƼöµÄÊý¾Ý¿âÁ¬½Ó×é¼þ
bsddb3£ºBerkeleyDBµÄÁ¬½Ó×é¼þ
Cheetah-1.0£ºÎұȽÏϲ»¶Õâ¸ö°æ±¾µÄcheetah
cherrypy£ºÒ»¸öWEB framework
ctypes£ºÓÃÀ´µ÷Óö¯Ì¬Á´½Ó¿â
DBUtils£ºÊý ......