![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
python3练习题
文章平均质量分 88
touchfl0w
code first!
展开
-
python3练习题:1-10
#practice1:在字典、列表、集合中按条件筛选数据列表解析#如何在列表、字典、集合中按条件筛选数据from random import randintfrom timeit import timeit#因为for提取的变量在randint函数中未使用,所以用_,而非一个变量名a = [randint(-10,10) for _ in range(10)]print(...原创 2018-06-11 09:33:36 · 5614 阅读 · 0 评论 -
python3练习题:11-20
practice11: excel读写(xlsx文件)1、 excel读excel内容import xlrd#不可以使用~来代替/home/openlabbook = xlrd.open_workbook('/home/openlab/Desktop/test.xls')#一个book含有两张sheet,可以看到返回了两个sheet objectprint(book.sh...原创 2018-06-19 17:01:00 · 2793 阅读 · 0 评论 -
python3练习题:并发编程(21-25)
#practice21:多线程线程的定义方法一:直接Thread()构造方法二:构造Thread的子类#多线程的使用from urllib.request import urlretrieveimport csvfrom xml.etree.ElementTree import ElementTree,Elementfrom threading import...原创 2018-07-04 11:10:58 · 1646 阅读 · 0 评论 -
python3装饰器的高级使用
#practice26:缓存与装饰器(递归子问题)对于需要重复计算子问题的情况,可以使用缓存,缓存实现有两种方式:1.在函数内定义某种数据结构存储数据 2.使用装饰器(闭包结构) 菲波那切数列为:1,1,2,3,5,8,13;即从第三项开始,每一项为前两项之和。以菲波那切数列为例1、一般的实现方式为:#求第n项的斐波那契数,从0开始def fibonacci(n):...原创 2018-07-27 23:31:46 · 671 阅读 · 0 评论 -
python3高级语法:__slots__属性、property装饰器、上下文管理协议、__new__方法
#practice29:派生内置不可变类型并修改其实例化行为(以tuple为例) __new__() is intended mainly to allow subclasses of immutable types (like int, str, or tuple) to customize instance creation. __init__()Called after...原创 2018-08-14 22:00:54 · 270 阅读 · 0 评论