Python代码
文章平均质量分 74
kermit0327
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
Python实现随机DNA序列,生成文件并匹配相似度文件
#导入模块import randomseed='ABCD'f=open('dna1.txt','w')for j in range(2000): s='' for i in range(20): s+=random.choice(seed) f.write('S'+str(j).zfill(5)+'\t'+s+'\n')f.flush()f.cl...原创 2019-02-23 09:05:17 · 2506 阅读 · 0 评论 -
用Python将字符串写入.txt文档,统计每个单词的个数并排序
# 读入文件‘monday.txt’.统计文件中每个单词的数量并且进行输出。# txt的文本文件为# Monday.txt的文本内容为# The pie chart above illustrates apparently the data of people doing exercise and the number of the gyms in a certain# city of c...原创 2019-02-27 19:27:55 · 3073 阅读 · 0 评论 -
Python函数小笔记
# 无参数无返回值def printinfo(): print('--------------') print('生命苦短我用Python') print('--------------')printinfo()# 有参函数def num_add(a,b): c = a+b print('a+b的结果:',c)num_add(3,5)# 函数...原创 2019-02-24 19:36:03 · 203 阅读 · 0 评论 -
Python基础练习代码持续更新。。。。。。。
一、有1、2、3、4个数字,能组成多少个互不相同且无重复数字的三位数?for i in range(1,5): for j in range(1,5): for k in range(1,5): if i != j and i!=k and k != j: print(i,j,k,end='|') print...原创 2019-03-05 20:39:46 · 785 阅读 · 0 评论 -
python多线程实现窗口卖票系统
例一、创建十个线程,卖100张火车票import threadinglist_ticket = []lock = threading.Lock() # 获取线程锁num = 100j = 0for i in range(1,num+1): ticket_num = '0'*(len(str(num))-len(str(i))) + str(i) list_ticke...原创 2019-03-15 09:41:09 · 4398 阅读 · 1 评论 -
python利用面向对象的思想实现功能代码练习
1.利用面向对象的思想,实现以下功能:(1)创建一个猫(Cat)类,其包含属性:名字(name)、品种(type)、价格(price)、颜色(color),并定义适当构造、析构的方法(2)创建一个老鼠(Mouse)类,其包含属性:名字(name)、颜色(color),并定义适当的构造、析构方法(3)在Cat类中定义一个属性cat_num,该属性存储的值为当前已实例化的猫的个数#(4)在...原创 2019-03-12 20:56:33 · 1848 阅读 · 0 评论
分享