![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
python
历史五千年
母校-太原工业学院
展开
-
PyCharm没有run选项,只有run nosetests in XXX
脚本写完后不能直接run该脚本,而是出现‘nosetests in ---’原因是:命名中不能出现test,包括类名和函数名原创 2019-10-16 22:29:31 · 1802 阅读 · 0 评论 -
python中coding=utf8 的作用
Python2:在python2中,解释器缺省使用ascii编码进行解释执行,在没有指定.py文件编码时,如果遇到中文字符,则直接报错:Non-ASCII character found, but no encoding declared。通过在.py文件第一行加上 # coding=utf-8/gbk,解释器就认为当前文件编码格式为utf-8/gbk,从而可以正确解释执行。...原创 2019-09-23 14:41:19 · 3392 阅读 · 0 评论 -
彻底搞懂python super函数的作用
super() 的入门使用在类的继承中,如果重定义某个方法,该方法会覆盖父类的同名方法,但有时,我们希望能同时实现父类的功能,这时,我们就需要调用父类的方法了。调用父类同名方法有两种方式:1、调用未绑定的父类方法2、使用super函数来调用先来说下第一种方式:调用未绑定的父类方法。演示:class Base(object): def greet(self): ...原创 2018-11-15 08:55:23 · 49250 阅读 · 45 评论 -
python threading模块、Timer类讲解
16.2.7. Timer Objects# The timer class was contributed by Itamar Shtull-Trauringdef Timer(*args, **kwargs): """Factory function to create a Timer object. Timers call a function after a spe...原创 2018-11-05 15:00:12 · 1843 阅读 · 0 评论 -
python threading模块、BoundedSemaphore类讲解
def BoundedSemaphore(*args, **kwargs): """A factory function that returns a new bounded semaphore. A bounded semaphore checks to make sure its current value doesn't exceed its initial val...原创 2018-11-05 14:08:19 · 5005 阅读 · 0 评论 -
python threading模块、Semaphore类讲解
16.2.5. Semaphore Objectsdef Semaphore(*args, **kwargs): """A factory function that returns a new semaphore. Semaphores manage a counter representing the number of release() calls minus ...原创 2018-11-05 11:08:21 · 7112 阅读 · 3 评论 -
python threading模块、Condition类讲解
16.2.4. Condition Objectsdef Condition(*args, **kwargs): """Factory function that returns a new condition variable object. A condition variable allows one or more threads to wait until they ...原创 2018-10-30 15:31:39 · 1061 阅读 · 0 评论 -
python threading模块、Lock类讲解
16.2.2. Lock ObjectsA primitive lock is a synchronization primitive that is not owned by a particular thread when locked. In Python, it is currently the lowest level synchronization primitive availab...原创 2018-10-24 16:46:36 · 1157 阅读 · 0 评论 -
python threading模块、Event类讲解
16.2.6. Event ObjectsThis is one of the simplest mechanisms for communication between threads: one thread signals an event and other threads wait for it.An event object manages an internal flag that...原创 2018-10-31 14:24:56 · 889 阅读 · 0 评论 -
python threading模块、RLock类讲解
16.2.3. RLock Objectsdef RLock(*args, **kwargs): """Factory function that returns a new reentrant lock. A reentrant lock must be released by the thread that acquired it. Once a thread ha...原创 2018-10-26 15:08:48 · 2751 阅读 · 0 评论 -
python threading模块、Thread类讲解
threading模块This module constructs higher-level threading interfaces on top of the lower level thread module.threading模块提供的类:Thread, Lock, Rlock, Condition, [Bounded]Semaphore, Event, Timer, local....原创 2018-10-23 16:17:43 · 1700 阅读 · 0 评论 -
python多线程编程初识
单线程整个程序只有一个执行流,所有的任务只能依次顺序执行。举例:假设在单线程环境下,有走路和唱歌两个任务,那么这两个任务只能顺序执行了哦。(也就是只能先走路,然后再唱歌,听起来是不是很变扭)# coding:gbkfrom time import ctime,sleepdef walk(): print 'I was walking. %s' % ctime() sl...原创 2018-10-22 17:20:34 · 135 阅读 · 0 评论 -
各种字符集和编码详解
编码产生在计算机中,所有的数据在存储和运算时都要使用二进制数表示(因为计算机用高电平和低电平分别表示1和0),例如,像a、b、c、d这样的52个字母(包括大写)、以及0、1等数字还有一些常用的符号(例如*、#、@等)在计算机中存储时也要使用二进制数来表示,而具体用哪些二进制数字表示哪个符号,当然每个人都可以约定自己的一套(这就叫编码),而大家如果要想互相通信而不造成混乱,那么大家就必须使用相同的...原创 2018-09-29 11:25:23 · 745 阅读 · 0 评论 -
python字符串处理方式以及解决字符串乱码不再是难题
简介相信很多程序员都碰到过字符串乱码的问题,有的人初步分析下就容易定位出问题来,而有的人就像无头苍蝇一样,就是瞎撞,gbk不好使,就换utf-8,再不行decode,encode…,一堆尝试。其实,一开始,我也是一样,对字符集不是很懂,不管是使用c/c++编程,还是python,只要碰到程序里有中文了,就不知所措,花了几天时间研究了字符集相关知识,总算有点收获。大体列举如下注意事项:要处理...原创 2018-09-28 11:55:53 · 4780 阅读 · 3 评论 -
python安装
官网地址:https://www.python.org1、windows下安装1、进入官网后,依次点击downloads->all releases 2、选择一个你想要的版本,点击右侧的Download 3、根据操作系统位数,选择对应的版本 4、我这里下载后的文件为python-2.7.15.amd64.msi,双击安装即可。 2、linux下安装linu...原创 2018-06-26 14:32:04 · 248 阅读 · 0 评论