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

python ÈÕÖ¾ÎÊÌâ


ÎÒÔËÐÐһϳÌÐò£º
import logging

def initlog():

    logger = logging.getLogger()
    hdlr = logging.FileHandler('D:\log_fram.log')
    formatter = logging.Formatter('%(asctime)s %(levelname)s %(message)s')
    hdlr.setFormatter(formatter)
    logger.addHandler(hdlr)
    logger.setLevel(logging.NOTSET)

    return logger

if __name__ == "__main__":
    loger = initlog()
    loger.info("Now the come return of the king!")

²åÈëÎļþûÓÐÎÊÌ⣬µ«ÊÇΪʲôµÚÒ»´ÎÔËÐвåÈëÒ»Ìõ,µÚ¶þ´Î²åÈëÁ½Ìõ£¬µÚÈý´Î²åÈëÈýÌõ£¬ÒÔ´ËÀàÍÆ£¡
²»ÖªµÀÊÇʲôԭÒòÇëÖ¸½Ì£¡


ÊÔÁËÄãµÄ½Å±¾£¬Õý³£¶î£¬Ã¿´ÎÒ»Ìõ¡£ÎҵĻ·¾³ÊÇPython 2.6.3 for Windows XP¡£

Õâ¸úÎļþ´ò¿ªËùÓÃµÄ mode Óйأ¬Ä¬ÈÏÊÇÒÔ append ´ò¿ªµÄ

Python code:
class FileHandler( filename[, mode])

Returns a new instance of the FileHandler class. The specified file is opened and used as the stream for logging. If mode is not specified, 'a' is used. By default, the file grows indefinitely.



¼¸ÖÖÎļþµÄ´ò¿ª·½Ê½£¬Ò²Ö»ÓÐaÊʺϰ¡£¬Ä¬ÈϾÍÊÇa£¬²»Ð´Ò²Ã»ÓÐʲôÎÊÌ⣡
angel_su ˵¿ÉÒÔ£¬ÄÇÊÇʲôԭÒòÄØ£¡£¿
ÎÒÓõÄÊÇpython2.5.2&


Ïà¹ØÎÊ´ð£º

pythonÔõôprint 'hello world'

´ó¼ÒºÃ£¬ÎÒÊÇÒ»¸öÐÂÊÖ£¬¸Õ¿ªÊ¼Ñ§python£¬µ«ÊǸտªÊ¼µÄhelloworld¶¼Ã»·¨´òÓ¡£¬ÈÃÎÒºÜÎÞÄΡ£
ÎÒµÄpython°²×°Â·¾¶Îªf:\python31¡£ÔÚpathÖÐÒ²ÉèÖöÔÁË£¬ÔÚwindowsÏÂÔËÐÐÊÇÕâÑùÏÔʾµÄ£¬Ï£Íû¸÷λǰ±²Ö¸µãһϡ£Ð»Ð»
Pyth ......

¶®pythonµÄjava¸ßÊÖÇë½Ì - Java / Java SE

ÇëÎʸßÊÖ£¬pythonÀïµÄpopenÀàËÆjavaÀïµÄÄĸöÀà»òÕß·½·¨ÄØ£¿£¿ÁíÍâjython¿ª·¢java¸ÃÈçºÎʹÓÃjythonÄØ£¿£¿
1.¿ÉÄܺÍjavaÀïµÄRuntime.getRuntime().exec£¨"ϵͳÃüÁî"£©; Æô¶¯½ø³Ì
2.eclipseÏÂÔØjython ²å¼ ......

python list for Ñ­»·ÎÊÌâ

Python code:

p=[1,2,3,4,5,6]
while True:
for i in p:
if i==4:
p=[]
f=[9,8,7]
p.extend(f)
break
print i£¬',',
p. ......

python Îļþ±¸·Ý´íÎó

#! c:\python26
# Filename: backup_ver1.py
import os
import time
source=[r'C:\test', r'C:\test1']
target_dir='D:\\back\\'
target=target_dir+time.strftime('%Y%m%d%H%M%S')+'.zip'
zip_command=" ......

ÈçºÎ½«Ò»¶ÎPython´úÂëÉú³É¿â

ÈçºÎ½«PythonдµÄÒ»¶Î´úÂëÉú³ÉpydÐÎʽµÄ¿â?
ÎÒÖªµÀµÄ·½·¨ÓУº½«Õâ¶ÎPython´úÂëÀ©Õ¹³ÉC´úÂ룬Ȼºóͨ¹ýVC½«Õâ¶ÎC´úÂëÉú³Éºó׺Ϊ.pydµÄ¶¯Ì¬Á´½Ó¿â¡£
²»ÏëÓÃÕâô±¿µÄ·½·¨£¬ÇëÎÊÓÐûÓбȽϼòµ¥µÄ·½·¨£¿Ð»Ð»£¡
¶¥Ò»Ï£¬ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ