![](https://img-blog.csdnimg.cn/20201014180756925.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
python
DQM_Venus
这个作者很懒,什么都没留下…
展开
-
数据的去重与排序-Python
from random import randintls = []h = int(input("输入个数:"))for i in range(h): ls.append(randint(1, 1000))ls = list(set(ls))ls.sort()print(ls)原创 2020-11-05 14:19:52 · 193 阅读 · 0 评论 -
统计单一数字的个数-Python
txt = list(input("输入数字(用逗号分割):"))s1 = set(txt)for num in s1: txt.remove(num)s2 = set(txt)count = len(s1)-len(s2)print("单一数字的个数为:{}".format(count))原创 2020-11-04 14:22:50 · 292 阅读 · 0 评论 -
星号金字塔-Python
a = 2 * eval(input("输入金字塔层数:"))for i in range(1, a+1, 2): b = (a-i)//2 print(' '*b, '*'*i)每行有奇数个星号组成。原创 2020-11-03 11:40:00 · 3516 阅读 · 0 评论 -
字典键值互换-Python
a1 = {'a': 1, 'b': 2, 'c': 3, 'd': 4}a2 = {}for i in list(a1.items()): a2[i[1]] = i[0]print(a2)原创 2020-11-02 14:01:12 · 350 阅读 · 0 评论 -
小写字符分布-Python
a, b = {}, ''txt = input("输入:")for i in "!@#$%^&*(){:'}?/|\_,.<>;`~-=+": # 去除特殊符号 txt = txt.replace(i, '')for j in txt: # 筛选小写字母 if ord('a') <= ord(j) <= ord('z'): a[j] = a.get(j, 0)+1items = list(a.items())items.sort原创 2020-10-31 11:15:57 · 164 阅读 · 0 评论