Python×°ÊÎÆ÷
Ò»¿ÅÓï·¨ÌÇ——×°ÊÎÆ÷
ÀíÂÛ²»È¥¹Ü£¬Ö»¹ÜÄÜ°ìÊ£º
1. ÎÒÒªÈÃÒ»¸öº¯ÊýÔÚÖ´ÐеÄʱºò£¬È¥×öһЩÊÂÇ飬±ÈÈ磬ÎÒÒª¿´¿´ÕâЩº¯ÊýÊDz»ÊÇÓÐdocstring£¬½«Õâ¸ö¹¦ÄÜÄóöÀ´£¬¶¨ÒåÒ»¸ö×°ÊÎÆ÷£º
def showmedoc(func):
if func.__doc__:
print 'has doc'
else:
print 'no doc'
return func #±ð×°ÊÎÁËÖ®ºó°ÑÈ˼ÒÔÀ´µÄº¯Êý¸ø¸ÇÁË£¬³ýÁËÐèÒªµÄÇé¿ö...
ºÍ×°ÊÎÉè¼ÆģʽÒìÇúͬ¹¤£¬²î²»¶à¾ÍÊÇÒ»¸ö¶«Î÷£¬ÏÂÃæ¾ÍÓÃËüÀ´°ìÊÂÇé ÁË£º
@showmedoc
def f1():
'''i have doc'''
pass
@showmedoc
def f2():
pass
Ö´Ðнá¹û£º
>>>
has doc
no doc
>>>
ÏÖÔÚµÄÇé¿öÊÇ£¬ÎÒÃÇÔÚ´úÂëÀﲢûÓе÷ÓÃf1,f2£¬ÎÒÃÇ֪ʶװÊÎÁËÒ»ÏÂËûÃÇ¡£È´ÓÐÊä³ö£¬ËµÃ÷ÔÚÖ´ÐеÄʱºò£¬½âÊÍÆ÷ÏÈɨÃè±»×°Êεĺ¯Êý£¬×°ÊκÃÁË£¬È»ºó¾ÍµÈן¯ÊýÖ´ÐÐÁË¡£
2.ÔÙ¿´¿´ÕâÑùµÄÇé¿ö£º
def say_hi():
print 'hello'
def showmedoc(func):
if func.__doc__:
print 'has doc '
else:
print 'no doc'
return say_hi
@showmedoc
def f1():
'''hello world'''
print "hihi"
f1()
µÃµ½Êä³ö£º
>>>
has doc
hello
>>>
ºÜÃ÷ÏÔ£¬ÎÒÃǸıäÁ˳ÌÐòµÄÈë¿Ú£¡ÎÒÃÇÖªµÀ£¬µÚÒ»ÐÐÊÇÔÚf1¶¨Òåʱ£¬±»×°ÊεÄʱºòÊä³öµÄ£¬ÒÔÅжÏËýÊDz»ÊÇÓÐdocstring¡£È»ºóÄØ£¬ÎÒÃǸıäÁ˳ÌÐòµÄÈë¿Úµ½say_hi¡£ÎÒÃÇÔÀ´µÄº¯ÊýʵÏÖ¸úÎÒÃÇ˵88ÁË£¬È¡¶ø´úÖ®µÄÊÇsay_hi¡£
3¡£¸ù¾ÝÉÏÏÂÎÄ»·¾³À´¸Ä±ä³ÌÐòµÄÈë¿Ú£º
ʵ¼ÊÓ¦ÓÃÖУ¬»áÓöµ½ÕâÑùµÄÇé¿ö£ºÎÒÃǸù¾ÝÓû§ÊÇ·ñÒѾµÇ½À´¸Ä±ä³ÌÐòµÄÖ´ÐÐÁ÷³Ì¡£
Óÿö£ºÎÒÃǵÄij¸ö´¦Àí¹ý³ÌÐèÒªÓû§µÄµÇ½ÐÅÏ¢£
Ïà¹ØÎĵµ£º
ÔÚparamikoÖÐʹÓÃÓû§ÃûºÍÃÜÂëͨ¹ýsftp´«ÊäÎļþ£¬²»Ê¹ÓÃkeyÎļþ¡£
import getpass
import select
import socket
import traceback
import paramiko
def putfile():
#import interactive
# setup logging
paramiko.util.log_to_file('demo.log')
username = username
hostname = hostname
......
http://sourceforge.net/projects/pyexcelerator/
12ÔÂ2ÈÕ
python ¶ÁдExcelÎļþ£¨×ªÌû limodou£©
http://www.lexicon.net/sjmachin/xlrd.htm
Õâ¸ö°üÊÇÓÃÀ´¶ÁExcelÎļþµÄ
ÔÚ·¢ÏÖ xlrd Ö®ºó²»¾Ã¾Í·¢ÏÖÁË pyExcelerator
£¬ËüÓë xlrd ²»Í¬£¬ËüÖ÷ÒªÊÇÓÃÀ´Ð´ Excel Îļþ£¬µ±È»¶ÁÒ²ÊÇûÓÐÎÊÌâµÄ¡£ÏÂÃæ¾ÍËüµÄʹÓüòµ¥µØ½éÉ ......
ÀµÓºƣ¨http://laiyonghao.com£©
½ñÌ죨2009Äê5ÔÂ31ÈÕ£© OurPNP.org ¸ãÁ˸ö¾Û»á»î¶¯£¬ÅªÁËÊ®¼¸¶þÊ®¸öÈËÔÚ¹ãÖݺ£Öé¹ã³¡µÄÌûá´ôÁËÎå¸öСʱ£¬´´ÏÂÁËÎÒÔÚ K ·¿´ôµÄ×ʱ¼ä¼Í¼¡£Ó¦ËûÃǵÄÑûÇ룬ÎÒ×öÁ˸öÌâΪ¡¶Óà python ¿ìËٴÍøÓηþÎñÆ÷¡·µÄСÑݽ²£¬ÒòΪÄDZߵĵçÊÓ¾¹È»²»ÄܽӵçÄÔ£¬ËùÒÔ½²µÄʱºòûÓÐÄܹ»²ÎÕÕ PPT À´½²£¬¹Û ......
Python 3 Êä³öÖض¨ÏòʹÓÃC/C++
By:gddsky
Ä¿±ê
Ï£Íû½«Python 3µÄÊä³öÖض¨Ïòµ½×Ô¶¨ÒåµÄÊä³öÄ¿±ê¡£
ºËÐÄ
PythonʹÓÃsys.stdout¡¢sys.stderr×öÊä³öÄ¿±ê£¬Ö»ÒªÎÒÃÇÌæ»»ÕâÁ½¸öÖµ¾Í¿ÉÒÔÖض¨Ïòµ½ÎÒÃÇ×Ô¶¨ÒåÄ¿±ê¡£Ìæ»»µÄÖµµÄ¹æÔòÔÚPythonµÄÎĵµÖÐsys (module)µÄsys.stdoutÉÏÃæ˵Ã÷Ö»ÒªÌí¼ÓÒ»¸öwriteº¯Êý¾Í¿ÉÒÔ ......