![](https://img-blog.csdnimg.cn/20201014180756916.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
入门练手
Coulson`Leo
新手上路
展开
-
python 读取文本内容 祛除重复行 逐行写入文本
不得不说python的库是很强大的,很多其他语言可能要很多行才能解决的问题在python中调用一下他对应功能的库函数就能做到。话不多说,上代码:with open('/Users/Administrator/Documents/one.txt') as file1: tmp = file1.read().splitlines() tmp1 = set(tmp)#利用内置的列表去重方法工...原创 2018-04-08 19:28:04 · 3380 阅读 · 0 评论 -
python 生成激活码 (指定数量以及指定长度)
import random, string#引用两个模块def rand_str(num, length):#这里的num用于指定数量,length用于指定长度 f = open("/Users/Administrator/Documents/py_need/The output.txt", 'w')#指定以写的方式打开指定文件,为了保存生#成的激活码 for i in range(n...原创 2018-04-14 19:50:57 · 923 阅读 · 0 评论