ÓÃpython½øÐÐÎļþ±È½ÏµÄÎÊÌâ
ÔÚPython for unix and linux System AdministrationÕâ±¾ÊéµÄµÚ6ÕµÄComparing DataÒ»½ÚÌáµ½ÓÃfilecmpÕâ¸öÄ£¿éµÄcmpº¯ÊýÀ´ÅжÏ2¸öÎļþÊÇ·ñÏàͬ¡£
ÈçÏÂËùʾ£º
Python code:
import filecmp
filecmp.cmp('file1.txt','file2.txt')
Èç¹û2¸öÎļþÄÚÈÝÏàͬ£¬Ôò·µ»ØTrue £¬·ñÔò·µ»ØFalse
±¾À´¿´µ½Õâ¾õµÃ¶¼Ã÷°×ÁË£¬ÓÖ¿´µ½ÕâÑùÒ»¾ä»°£º
The filecmp module contains functions for doing fast and efficient comparisons of files
and directories. The filecmp module will perform a os.stat on two files and return a
True if the results of os.stat are the same for both files or a False if the results are not.
Typically, os.stat is used to determine whether or not two files use the same inodes
on a disk and whether they are the same size, but it does not actually compare the
contents.
ÕâÀï˵filecmp.cmpÊÇͨ¹ýµ÷ÓÃ2¸ö·½·¨µÄos.stat()·µ»Ø½á¹û£¨ÊÇ·ñʹÓÃÁË´ÅÅÌÉϵÄÏàͬ½Úµã¡¢Îļþ´óСÊÇ·ñÏàµÈ)À´ÅжÏÎļþÊÇ·ñÏàͬ£¬Êµ¼ÊÉϲ¢Ã»¶ÔÎļþÄÚÈݽøÐбȽϡ£ÎÒÕâÀïºÜ²»Ã÷°×£¬²»ÖªµÀÕâÑù×öµÄÔÀíÊÇʲô£¿
ÁíÍâÔÙÎÊÒ»¾ä£¬¿ÉÒÔÓÃMD5УÑéºÍÀ´ÅжÏÎļþÊÇ·ñÍêÈ«ÏàͬÂð£¬Èç¹û¿ÉÒÔ£¬Ò»°ãÊÊÓÃÓÚʲô³¡ºÏ¡£ºÍÉÏÃæµÄ·½·¨Ïà±ÈÓÐʲôÓÅȱµã£¿
inode ½á¹¹ºÍÏà¹ØÁªµÄ²Ù×÷
»¹ÊDz»Ì«Ã÷°×inodeºÍÎļþÄÚÈݵĹØϵ£¬ÎªÊ²Ã´¿ÉÒÔÖ»ÅжÏinodeÄØ£¿
ÓÐûÓпÉÄÜinodeÏàͬµ«ÎļþÄÚÈݲ»Í¬£¬»òÕßÎļþÄÚÈÝÏàͬµ«inode²»Í¬£¿
Âé·³DarkCh
Ïà¹ØÎÊ´ð£º
ÒÑÖªPython ÖУº
s = unicode("²âÊÔ", "gb2312")
s = u'\u6d4b\u8bd5'
print s
²âÊÔ
ÔÚDelphiÀïÃæÈçºÎ½«\u6d4b\u8bd5ÕâÑùµÄ»¹Ô³ÉGb2312µÄºº×ÖÄØ£¿
ÕÒµ½¸ö·½·¨
......
ÎÒÿ´ÎÉÏ´«µÄÎļþ¶Áµ½µÄÊý¾Ý¶¼²»ÕýÈ·¡£2M µÄͼƬ¶ÁµÃ10¶àK ¡£¡£ÄÄλ´óÏÀ¿ÉÒÔ°ï°ïÎÒ°¡¡£
#!D:\ProgrammerTools\python26\python.exe
#encoding=utf-8
import cgitb
import os
cgitb.enable()
import cgi,urllib ......
ÔÚlistÖÐÌí¼ÓÒ»¸öÀàµÄ¾Ö²¿±äÁ¿ ÕâÑù×öÊÇ·ñºÏ·¨ Çë¿´ÏÂÃæÀý×Ó:
Python code:
class A():
def __init__( self ):
self.__a = 0
self.__b = 'hello'
def get_a( self ):
ret ......
ÔÚÎı¾ÎļþÖÐÆ¥ÅäÏî°üº¬ÖÐÎÄ
ÈçÄÚÈÝΪ£ºgamename=ÖÐÎÄ
key=ÌìÏÂ
Îı¾ÎļþµÄ±àÂëµÄÎļþΪutf-8
python´úÂëÈçÏ£º
# -*- coding:UTF-8 -*-
contents=open(from_pa ......
ѧϰpythonµÄ7±¾Êé
°üÀ¨6±¾chm£¬Ò»±¾pdf×ÊÁÏ
¶ÔѧϰpythonÓкܴóµÄ°ïÖú
http://download.csdn.net/source/619791
¾«ÐÄËѼ¯£¬²»Òª»ý·Ö£¬ÄóöÀ´·ÖÏí
лл¥Ö÷£¬ÐÁ¿àÁË~
lz ×îºÃ°ÑÊéÃûºÍ¼òµ¥½éÉܼÓÉ ......