![](https://img-blog.csdnimg.cn/20201014180756780.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
Python 3
Hello_World_Learner
这个作者很懒,什么都没留下…
展开
-
ASCII 与 Int
# ord() char -> ASCII # chr() ASCII -> chardef toint( ch ): ch = str( c h); # from hex to dec etc if( ch >= '0' and ch return int( ch ); else: return 10 +原创 2015-11-22 22:19:40 · 636 阅读 · 0 评论 -
正则表达式入门
import re;txt = "this is a good thing, that is a bad thing";rule1 = ["this", "that", "a"];p = list( re.compile(p) for p in rule1 );for i, r in enumerate(p): print( i, r ); for x in r.finditer原创 2015-12-13 22:03:39 · 329 阅读 · 0 评论 -
魔性的 turtle 入门
#3 Hello Turtlesimport turtlesc = turtle.Screen();sc.bgcolor("lightgreen") sc.title("Hello World");ai = turtle.Turtle();ai.color("pink");ai.shape("turtle");ai.pensize(5);ai.speed(0); #原创 2015-11-29 22:24:43 · 425 阅读 · 0 评论 -
逐行快速读入
f = open("output.txt","w");# lazy readlinefor line in open("lx.txt"): f.write(line);f.close();原创 2015-11-29 22:27:22 · 349 阅读 · 0 评论 -
网络爬虫入门
import urllib.request;import re; url = "http://news.xinhuanet.com/politics/2015-12/20/c_128549058.htm";data = urllib.request.urlopen(url);# 返回对象,有各种方法txt = data.read().decode("utf-8","ignore"); #原创 2015-12-20 21:16:17 · 406 阅读 · 0 评论 -
括号套括号的计数
def count(tar, a): tot,tar= 0,str(tar); for v in a: if type(v) == type([]): #判定是否有嵌套 tot += count(tar, v); else: tot += (tar == str(v)); return tot;原创 2015-12-06 21:58:02 · 663 阅读 · 0 评论 -
字符串快速过滤
keep = "1 2 3 4 5 6 7 8 9 0".split();a = "adfh23aks4j5dh234fe3412uiw1\n!";# lazy filternew_a = "".join(ch for ch in a if ch in keep);原创 2015-12-06 21:54:20 · 476 阅读 · 0 评论