![](https://img-blog.csdnimg.cn/20201014180756754.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
python
hfdwdjl
这个作者很懒,什么都没留下…
展开
-
Python中正则表达式的应用
最近接触python,感觉正则表达式又忘了不少了……看到这篇文章不错,转过来做一下记录!点击打开链接转载 2014-12-21 16:34:23 · 386 阅读 · 0 评论 -
学习Python4(hashlib)
测试程序#coding:utf8import hashlibprint dir(hashlib)print hashlib.__all__# print hashlib.__builtins__# print hashlib.__doc__print hashlib.__file__print hashlib.__get_builtin_constructorprint hashli原创 2015-06-16 23:05:15 · 792 阅读 · 0 评论 -
学习Python5(Thread)
测试代码#coding:utf8import thread, time, randomprint '-'*25, '测试1', '-'*25count = 0lock = thread.allocate_lock()def threadTest(): global count, lock lock.acquire() for i in xrange(1000000):转载 2015-06-18 00:37:36 · 582 阅读 · 0 评论 -
学习Python6(临时计算器+字符串编码)
临时计算器交互模式中,最近一个表达式的值赋给变量 _。这样我们就可以把它当作一个桌面计算器,很方便的用于连续计算,例如:>>> tax = 12.5 / 100>>> price = 100.50>>> price * tax12.5625>>> price + _113.0625>>> round(_, 2)113.06此变量对于用户是只读的。不要尝试给它赋值 —— 你只会创建一个独转载 2015-06-24 10:39:48 · 672 阅读 · 0 评论 -
学习Python7(流程控制)
迭代链表索引需要迭代链表索引的话,如下所示结合使用 range() 和 len():>>> a = ['Mary', 'had', 'a', 'little', 'lamb']>>> for i in range(len(a)):... print i, a[i]...0 Mary1 had2 a3 little4 lamb循环中的else循环可以有一个 else 子句;它在转载 2015-06-24 11:58:28 · 466 阅读 · 0 评论 -
学习Python2(正则表达式)
感谢crossin大神!# 调用范例import retext = "Hi, I am Shirley Hilton. I am his wife."m = re.findall(r"hi", text) #把所有符合要求的存到列表中if m: print melse: print 'not match'#贪婪匹配m = re.findall(r"I.*e", text转载 2015-06-09 18:34:52 · 1732 阅读 · 0 评论 -
学习Python3(随机数)
random 模块的作用是产生随机数。之前的小游戏中用到过 random 中的 randint: import randomrandom.seed(x) #指定 seed。num = random.randint(1,100) #包括1和100的随机整数。random.uniform(a, b) #生成 a、b 之间的随机浮点数。不过与 randint 不同的是,a、b无需是整数,也不用考虑大转载 2015-06-11 23:33:39 · 4002 阅读 · 0 评论