python֮ǿ´óµÄÈÕ־ģ¿é¡¾×ª¡¿
1.¼òµ¥µÄ½«ÈÕÖ¾´òÓ¡µ½ÆÁÄ»
import
logging
logging.
debug(
'This is debug message'
)
logging.
info(
'This is info message'
)
logging.
warning(
'This is warning message'
)
ÆÁÄ»ÉÏ´òÓ¡:
WARNING:root:This is warning message
ĬÈÏÇé¿öÏ£¬logging½«ÈÕÖ¾´òÓ¡µ½ÆÁÄ»£¬ÈÕÖ¾¼¶±ðΪWARNING£»
ÈÕÖ¾¼¶±ð´óС¹ØϵΪ£ºCRITICAL > ERROR > WARNING > INFO > DEBUG > NOTSET£¬µ±È»Ò²¿ÉÒÔ×Ô¼º¶¨ÒåÈÕÖ¾¼¶±ð¡£
2.ͨ¹ýlogging.basicConfigº¯Êý¶ÔÈÕÖ¾µÄÊä³ö¸ñʽ¼°·½Ê½×öÏà¹ØÅäÖÃ
import
logging
logging.
basicConfig(
level=
logging.
DEBUG,
format=
'%(asctime)s %(filename)s[line:%(lineno)d] %(levelname)s %(message)s'
,
datefmt=
'%a, %d %b %Y %H:%M:%S'
,
filename=
'myapp.log'
,
filemode=
'w'
)
logging.
debug(
'This is debug message'
)
logging.
info(
'This is info message'
)
logging.
warning(
'This is warning message'
)
./myapp.logÎļþÖÐÄÚÈÝΪ:
Sun, 24 May 2009 21:48:54 demo2.py[line:11] DEBUG This is debug message
Sun, 24 May 2009 21:48:54 demo2.py[line:12] INFO This is info message
Sun, 24 May 2009 21:48:54 demo2.py[line:13] WARNING This is warning message
logging.basicConfigº¯Êý¸÷²ÎÊý:
filename: Ö¸¶¨ÈÕÖ¾ÎļþÃû
filemode: ºÍfileº¯ÊýÒâÒåÏàͬ£¬Ö¸¶¨ÈÕÖ¾ÎļþµÄ´ò¿ªÄ£Ê½£¬'w'»ò'a'
format: Ö¸¶¨Êä³öµÄ¸ñʽºÍÄÚÈÝ£¬format¿ÉÒÔÊä³öºÜ¶àÓÐÓÃÐÅÏ¢£¬ÈçÉÏÀýËùʾ:
%(levelno)s: ´òÓ¡ÈÕÖ¾¼¶±ðµÄÊýÖµ
%(levelname)s: ´òÓ¡ÈÕÖ
Ïà¹ØÎĵµ£º
#---------------------תתתתתתתתתתתתתתתתתתתתתתת-------------------------------------------#
Python×÷ΪһÖÖ¹¦ÄÜÇ¿´óÇÒͨÓõıà³ÌÓïÑÔ¶ø¹ãÊܺÃÆÀ£¬Ëü¾ßÓзdz£ÇåÎúµÄÓï·¨Ìص㣬ÊÊÓÃÓÚ¶àÖÖ²Ù×÷ϵͳ£¬Ä¿Ç°ÔÚ¹ú¼ÊÉϷdz£Á÷ÐУ¬ÕýÔڵõ½Ô½À´Ô½¶àµÄÓ¦Óá£
¡¡¡¡ÏÂÃæ¾ÍÈÃÎÒÃÇÒ»ÆðÀ´¿´¿´ËüµÄÇ¿´ó ......
¼Ìǰƪ¡¶Import Module¡·£¨http://blog.csdn.net/xiadasong007/archive/2009/09/02/4512797.aspx£©£¬¼ÌÐø·ÖÎöǶÈ벿·Ö»ù´¡ÖªÊ¶¡£Õâ´Î²»¶à˵£¬ÓÐʲôÎÊÌâ¼ÇµÃ¶à²éÓ¢ÎÄ×ÊÁÏ£¬¹úÄÚµÄÕâ·½Ãæ֪ʶÉÙ
»¹ÊÇÀ´¿´´úÂ룬дÍêÎÒ¾Í˯¾õÁË~
#include "python/python.h"
#include <iostream>
using namespace std;
int ......
Python lists have a built-in sort() method that modifies the list in-place and a sorted() built-in function that builds a new sorted list from an iterable.
There are many ways to use them to sort data and there doesn't appear to be a single, central place in the various man ......
¿Í»§¸øÒ»¶ÑͼƬҪ´«µ½ºǫ́£¬Í¼Æ¬Ì«´óÁË£¬ÉÏ°ÙÕÅͼÓÃphotoshop¸ÄÌ«Âý£¬¾ÍÏëµ½ÓÃpythonд¸ö¼òµ¥µÄÅú´¦Àí¡£¹¦Äܼòµ¥¾ÍÊÇ°ÑÔͼ°´±ÈÀýËõС£¬´úÂë¸ü¼òµ¥ 20¶àÐС£
# -*- coding: cp936 -*-
import Image
import glob, os
#ͼƬÅú´¦Àí
def timage():
for files in glob.glob('D:\\1\\*.JPG'):
filepath,filena ......