ÓÃ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
Ïà¹ØÎÊ´ð£º
ÔÚÎı¾ÎļþÖÐÆ¥ÅäÏî°üº¬ÖÐÎÄ
ÈçÄÚÈÝΪ£ºgamename=ÖÐÎÄ
key=ÌìÏÂ
Îı¾ÎļþµÄ±àÂëµÄÎļþΪutf-8
python´úÂëÈçÏ£º
# -*- coding:UTF-8 -*-
contents=open(from_pa ......
ÇëÎʸßÊÖ£¬pythonÀïµÄpopenÀàËÆjavaÀïµÄÄĸöÀà»òÕß·½·¨ÄØ£¿£¿ÁíÍâjython¿ª·¢java¸ÃÈçºÎʹÓÃjythonÄØ£¿£¿
1.¿ÉÄܺÍjavaÀïµÄRuntime.getRuntime().exec£¨"ϵͳÃüÁî"£©; Æô¶¯½ø³Ì
2.eclipseÏÂÔØjython ²å¼ ......
C#ÀïÃæÓÃusing System.Security.Cryptography; RSACryptoServiceProvider¼ÓÃܹýµÄÏûÏ¢
ÓÃPython CryptoÖÐRSAµÄ·½·¨ ÄÜÖ±½Ó ½âÂð£¿
RSA¼ÓÃÜ·½Ê½²»ÊÇͳһµÄÂð£¿ÐèҪעÒâЩʲô£¿
ÓаïÖú¡£µ«ÊÇû½â¾öÎÊÌâ¡£¡£¡£
......
#! 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 django ¿ª·¢µÄ³ÌÐò »òÕßÖªµÀÄÄÓÐ
¸æËßÏ ÎÒÒªÒ»¸ö¿ªÔ´µÄ³ÌÐòѧϰÓà ¸Ð¾õ×Ô¼º±à³ÌºÜ²»¹æ·¶
µã»÷²é¿´¡¶Django Web ¿ª·¢Ö¸ÄÏ¡·
http://www.ibm.com/developerworks/cn/linux/l-django/
Äã˵µÄÊÇdj ......