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

首頁 > 編程 > Python > 正文

Python實(shí)現(xiàn)字典去除重復(fù)的方法示例

2020-01-04 17:06:05
字體:
供稿:網(wǎng)友

本文實(shí)例講述了Python實(shí)現(xiàn)字典去除重復(fù)的方法。分享給大家供大家參考,具體如下:

#!/usr/bin/env python# encoding: utf-8#字典去重小代碼import sysimport osimport platformtry:  pass except:  print '''you have something wrong this is a simple jiaoben '''  sys.exit()why = 'why.txt'for i in xrange(len(sys.argv)):  if(i>=1):    other = sys.argv[i]    if os.path.exists(other):      pass    else:      print other + ' file not find'      sys.exit()    if 'Windows' in platform.system():      os.system("type "+other+" >> "+why)    else:      os.system("cat "+other+" >> "+why)yuan = open('why.txt','r')dirc = open('whynot.txt','w')for line in set(yuan.readlines()):  if line == '' or line == '/r/n':    pass  else:    dirc.writelines(line)

很簡單的思路 把文件放入到why.txt中 然后再去重得到whynot.txt
Usage: quchong.py 1.txt 2.txt 3.txt 等等

 

希望本文所述對大家Python程序設(shè)計(jì)有所幫助。

發(fā)表評論 共有條評論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 兴业县| 绥滨县| 枞阳县| 清镇市| 巴彦县| 谢通门县| 樟树市| 大宁县| 郎溪县| 巴林左旗| 香港| 卫辉市| 桐柏县| 天全县| 台东县| 延边| 亚东县| 广东省| 蛟河市| 和田市| 昆山市| 双峰县| 报价| 博湖县| 柏乡县| 齐齐哈尔市| 武邑县| 扬中市| 克什克腾旗| 高要市| 开江县| 弋阳县| 新沂市| 沭阳县| 两当县| 长岛县| 南乐县| 蒙阴县| 博乐市| 阿坝| 喀什市|