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

»ù±¾Êý¾Ý½á¹¹µÄpythonʵÏÖ ¶ÓÁÐ

¶ÓÁУº
Óë¶ÑÕ»ÀàËÆ£¬Í¨¹ýpythonµÄÁбíÀàÐÍÀ´ÊµÏÖ£¬²Î¿¼ help(list)
shoplist=['apple','mango','carrot','banana']
print 'I have',len(shoplist),'items to purchase'
print 'these items are:'
for item in shoplist:
print item,
shoplist.append('rice')
print 'my shopping list is now', shoplist
shoplist.sort()
print 'Sorted shopping list is',shoplist
olditem=shoplist[0]
del shoplist[0]
print 'I bought the',olditem
print 'My shopping list is now',shoplist


Ïà¹ØÎĵµ£º

»°ËµPython£¨¶þ£©ÔçÀ´µÄÎļþ

»°ËµPython£¨¶þ£©
 
×Ô´ÓС°×ÉÏÍêµÚÒ»¿Î£¬Python¼òÖ±³ÉÁËËûµÄ¿Æѧ¼ÆËãÆ÷¡£Ã¿ÌìÔçÉÏ£¬Ð¡°××ÜÊDz»Íü“Á·Ï°”Ò»ÏÂPython¡£
 >>> 10000*1.2**40
14697715.679690843
“ºÙºÙ£¬ÎÒ·¢´ïÁË£¡”С°×ÔÚɵЦ×Å£¬ºÃÏñÔÚ×öÃΣ¬“ËÄÊ®Äêºó¾ÍÊÇÒÚÍò¸»ÎÌÀ²!”
 Ð¡²ËÇÃÁËÇÃС°×µ ......

windows & python & Emacs


ÉèÖÃEmacsµÄHOME,¿ÉÒÔÔÚscratch bufferÖÐÊäÈ룺(insert (getenv "HOME"))²é¿´
ÏÂÔØpython-mode.el
ÓÃEmacs´ò¿ªpython-mode.elÈ»ºóM-x byte-compile-file±àÒëpython-mode.elΪelc
C-h v²é¿´load-path±äÁ¿
ÔÚHOME/.emacs.d/init.elÖÐÌí¼Ó(setq load-path (cons "D:\\emacs-23.1-bin-i386" load-path))
½«pyÎļþÓëpytho ......

python¸Ä±äÎļþ¼°Æä×ÓĿ¼µÄÊôÐÔ


1.¸Ä±ä±¾ÎļþµÄÊôÐÔ
import
os
import
stat
os.chmod( filename, stat.S_IWRITE )
2.¸Ä±ä±¾Ä¿Â¼¼°Æä×ÓĿ¼ÊôÐÔ
import
os
os.system(r
'
attrib -r' + path +'\\*.* /s
'
)
3.½éÉܸıäÎļþÊôÐÔµÄdosÖ¸Áî
Attrib
ÏÔʾ¡¢ÉèÖûòɾ³ýÖ¸ÅɸøÎļþ»òĿ¼µÄÖ»¶Á¡¢´æµµ¡¢ÏµÍ³ÒÔ¼°Òþ²ØÊôÐÔ¡£Èç¹ûÔÚ²»º¬²ÎÊýµÄÇ ......

LinuxÏÂpython lxmlÄ£¿éµÄ°²×°

ÐèÒªÏÈ°²×°libxml2-devel libxslt-develÕâÁ½¸örpm°ü£¬Èç¹ûʹÓ÷ÇrootÓû§°²×°£¬¿ÉÒÔÏÂÔØlibxml2ºÍlibxsltµÄÔ´´úÂë½øÐа²×°¡£ libxml2-devel¡¢libxslt-devel×°ºÃºó£¬½âѹlxmlµÄ°ü£¬Çл»µ½Õâ¸ö°üµÄ·¾¶¡£
¼ÓÈëCFLAGS½øÐбàÒëºÍ°²×°£¬ÔÚshellÏÂÒÀ´ÎÊäÈëÈçÏÂÃüÁ CFLAGS=-I/usr/include/libxml2:/usr/include/libxslt/ ......

pythonµÄ±ä²Î


pythonµÄ±ä²Î
*argsºÍ**dargsÊÇPythonµÄÁ½¸ö¿É
±ä²ÎÊý£¬Á½ÕßÓÐËù²»Í¬µÄÊÇ*argsÊǸötuple£¬**dargsÊǸödict¡£
*args
ºÍ**dargs²¢ÓÃʱ£¬*args±ØÐë·ÅÔÚ**dargsµÄÇ°Ãæ¡£
ÀýÈ磺
def func(a,b, *c):
    pass
º¯ÊýfuncÖÁÉÙÓÐÁ½¸ö²ÎÊý±ä²ÎÊý·ÅÔÚtuple  cÖÐ
def func(*c): »òÕß def  func(**d ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ