本文实例讲述了python统计文本字符串里单词出现频率的方法。分享给大家供大家参考。具体实现方法如下:
# word frequency in a text
# tested with Python24 vegaseat 25aug2005
# Chinese wisdom ...
str1 = """Man who run in front of car, get tired.
Man who run behind car, get exhausted."""
print "Origin
本文实例讲述了python实现比较两段文本不同之处的方法。分享给大家供大家参考。具体实现方法如下:
# find the difference between two texts
# tested with Python24 vegaseat 6/2/2005
import difflib
text1 = """The World's Shortest Books:
Human Rights Advances in China
"My Plan to Find the Real Killer
本文实例讲述了python显示生日是星期几的方法。分享给大家供大家参考。具体实现方法如下:
# find the day of the week of a given date
# Python will trap impossible dates like (1900, 2, 29)
# tested with Python24 vegaseat 01aug2005
from datetime import date
# a typical birthday year, month,
本文实例讲述了python删除过期文件的方法。分享给大家供大家参考。具体实现方法如下:
# remove all jpeg image files of an expired modification date = mtime
# you could also use creation date (ctime) or last access date (atime)
# os.stat(filename) returns (mode, ino, dev, nlink, uid, gid, si
本文实例讲述了python定时执行指定函数的方法。分享给大家供大家参考。具体实现方法如下:
# time a function using time.time() and the a function decorator
# tested with Python24 vegaseat 21aug2005
import time
def print_timing(func):
def wrapper(*arg):
t1 = time.time()
res = func(