国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > Python > 正文

python 高效去重復 支持GB級別大文件的示例代碼

2020-01-04 14:08:19
字體:
來源:轉載
供稿:網友

如下所示:

#coding=utf-8 import sys, re, os def getDictList(dict):  regx = '''[/w/~`/!/@/#/$/%/^/&/*/(/)/_/-/+/=/[/]/{/}/:/;/,/.///</>/?]+'''  with open(dict) as f:    data = f.read()    return re.findall(regx, data) def rmdp(dictList):  return list(set(dictList)) def fileSave(dictRmdp, out):  with open(out, 'a') as f:    for line in dictRmdp:      f.write(line + '/n') def main():  try:    dict = sys.argv[1].strip()    out = sys.argv[2].strip()  except Exception, e:    print 'error:', e    me = os.path.basename(__file__)    print 'usage: %s <input> <output>' %me    print 'example: %s dict.txt dict_rmdp.txt' %me    exit()   dictList = getDictList(dict)  dictRmdp = rmdp(dictList)  fileSave(dictRmdp, out)   if __name__ == '__main__':  main()

以上這篇python 高效去重復 支持GB級別大文件的示例代碼就是小編分享給大家的全部內容了,希望能給大家一個參考,也希望大家多多支持VEVB武林網。


注:相關教程知識閱讀請移步到python教程頻道。
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 临沧市| 城固县| 云南省| 武穴市| 巩义市| 东安县| 静乐县| 色达县| 开平市| 诸城市| 南涧| 丹凤县| 临沂市| 巴塘县| 高州市| 青铜峡市| 星子县| 彭泽县| 体育| 三穗县| 咸阳市| 黑水县| 通山县| 乌审旗| 武山县| 鹿邑县| 静海县| 靖西县| 顺平县| 深圳市| 金昌市| 平谷区| 长武县| 耿马| 布尔津县| 逊克县| 镇宁| 武鸣县| 芜湖县| 金平| 抚远县|