Python实现字典去除重复的方法示例
发布时间:2020-12-17 08:13:03 所属栏目:Python 来源:网络整理
导读:本篇章节讲解Python实现字典去除重复的方法。供大家参考研究具体如下: #!/usr/bin/env python# encoding: utf-8#字典去重小代码import sysimport osimport platformtry: pass except: print '''you have something wrong this is a simple jiaobe
|
本篇章节讲解Python实现字典去除重复的方法。分享给大家供大家参考,具体如下:
#!/usr/bin/env python
# encoding: utf-8
#字典去重小代码
import sys
import os
import platform
try:
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 == 'rn':
pass
else:
dirc.writelines(line)
很简单的思路 把文件放入到why.txt中 然后再去重得到whynot.txt PS:本站还有两款比较简单实用的在线文本去重复工具,推荐给大家使用: 在线去除重复项工具: 在线文本去重复工具: 更多关于Python相关内容可查看本站专题:《Python字典操作技巧汇总》、《Python字符串操作技巧汇总》、《Python常用遍历技巧总结》、《Python数据结构与算法教程》、《Python函数使用技巧总结》及《Python入门与进阶经典教程》 希望本文所述对大家Python程序设计有所帮助。 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
