国产探花免费观看_亚洲丰满少妇自慰呻吟_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ā)表
主站蜘蛛池模板: 无锡市| 象州县| 福建省| 新营市| 綦江县| 伊川县| 潮州市| 平江县| 剑河县| 甘孜县| 宝应县| 民县| 龙里县| 彝良县| 达孜县| 曲水县| 梅州市| 咸宁市| 旬邑县| 辛集市| 开阳县| 息烽县| 日照市| 河北省| 大余县| 彭水| 虹口区| 正镶白旗| 庄浪县| 巩义市| 普格县| 昌吉市| 磐安县| 济宁市| 米脂县| 沁阳市| 汉阴县| 盘山县| 仙桃市| 江孜县| 铜川市|