Chinaunix首页 | 论坛 | 博客
  • 博客访问: 3625244
  • 博文数量: 880
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 6155
  • 用 户 组: 普通用户
  • 注册时间: 2016-11-11 09:12
个人简介

To be a better coder

文章分类

全部博文(880)

文章存档

2022年(5)

2021年(60)

2020年(175)

2019年(207)

2018年(210)

2017年(142)

2016年(81)

分类: LINUX

2019-01-21 10:29:00

[root@localhost /]# cat list.py
#!/bin/python
from random import randint
d=[randint(-10,10) for _ in range(10)]
s={'student%d' %i:randint(-10,10) for i in range(10)}
t=[x for x in d if x >=0]
#if (4,3)>(3,4):
#    print 'aaaaaaaaaaaa'
r=[(y,x) for x,y in s.items()]
print s
print r
print (sorted(r,reverse=1))
#print s
#print d
#print t
[root@localhost /]#
[root@localhost /]#
[root@localhost /]# cat len.py
#!/bin/python
from collections import Counter
from random import *
a=[randint(1,10) for _ in range(20)]
b={randint(1,10) for _ in range(5)}
c={'student%d' %i:randint(1,20) for i in range(10)}
d=[x for x in a if x>=5]
e={y for y in b if y>=5}
f=[(x,v) for v,x in c.items()]
haha=Counter(a)
str=haha.most_common(3)
print a
print b
print c
print d
print e
print f
print sorted(f)
print str
[root@localhost /]#


阅读(5145) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~