- 博客(6)
- 收藏
- 关注
原创 测试python程序运行时间
import timeimport decimal# text decimal_sumprint("decimal:")start =time.time()sum = decimal.Decimal('0')for x in range(100): sum += decimal.Decimal(x)end = time.time()# print('Running t...
2018-04-30 09:51:55 10364 1
原创 python中list,dict,set的总结
list基本特性 有序可变,元素可以是任何已知的数据结构初始化 a = [] a = [1,3,54] a = [1, '34', (2,4)] 增删改查a.append()a.extend()a.pop()a.pop(index)a[0] = 'need'a.clear()x in a遍历for x in l...
2018-04-24 20:33:04 5026
原创 python遍历字典以及list转化字典,求字典元素最大值
我们先来看这样一个故事:程序员加班回家,已经是深夜了,加上路途遥远,只好坐车回去,他现在想到的交通工具如下。costs = ['bike', 'car', 'bus', 'light railway']程序员想了想:for cost in costs: print(cost)各种交通工具的价格已经贴在墙上了:costs = [['bike', 2], ['c...
2018-04-18 21:13:12 1798
转载 jupyter notebook 关于不同版本py共存的问题
The idea here is to install multiple ipython kernels. Here are instructions for anaconda. If you are not using anaconda, I recently added instructions using pure virtualenvs.conda create -n py27 pyt...
2018-04-18 07:26:03 836
原创 python 中zip() 不同版本之间的差异, *表达式
1. zip()之前练习的时候写过这样的代码:items = ["bananas", "mattress", "dog kennels", "machine", "cheeses"]weights = [15, 34, 42, 120, 5]totals = zip(items, weights)for total in totals: print(total, end=' ...
2018-04-17 07:45:43 638
原创 python列表 sort和sorted的区别
对于一个指定的列表,如果想要对它进行排序,python内置了sort和sorted方法,那么这两者又有什么区别呢?准确的说,sorted是个函数,sort是方法。 下边看下python的官方文档。sort():a = [1,4,5,6,7,123,4,5]print(a)a.sort()print(a) sorted():b = [1,4,5,6,7,123,4,5]...
2018-04-16 12:58:43 4300 1
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人