python学习笔记(二)
来源:互联网 发布:java和安卓哪个好 编辑:程序博客网 时间:2024/06/08 02:29
29、关于文件输入参数,可以通过sysy.argv查看,但!Don’t implement option parsing yourself. Use modules such as optparse
, argparse
or :mod`docopt`.
30、os.listdir('.')
31、importlib.reload(demo)用于重加加载更改后新的模块
32、if __name__ == '__main__':
33、you should not write very long lines that span over more than (e.g.) 80 characters. Long lines can be broken with the \
character
-------------------------------------------------------------------------------------------------------------------
34、a = np.array(...) a.ndim, a.shape, len(a), np.arange(), np.linspace(), np.ones(tuple), np.zeros(tuple), np.eye()
35、
a = np.random.rand(4) # uniform in [0, 1]
36、
b = np.random.randn(4) # Gaussian
37、
a = np.random.randint(0, 21, 15)a[a % 3 == 0] = -1
38、
a = np.arange(10)>>> idx = np.array([[3, 4], [9, 7]])>>> idx.shape(2, 2)>>> a[idx]array([[3, 4], [9, 7]])
39、
= np.arange(10000)>>> %timeit a + 1 10000 loops, best of 3: 24.3 us per loop>>> l = range(10000)>>> %timeit [i+1 for i in l] 1000 loops, best of 3: 861 us per loop
40、Array multiplication is not matrix multiplication:, ## c.dot(c)
41、
np.array_equal(a, b)
42、
x = np.array([[1, 1], [2, 2]])>>> xarray([[1, 1], [2, 2]])>>> x.sum(axis=0) # columns (first dimension)array([3, 3])>>> x[:, 0].sum(), x[:, 1].sum()(3, 3)>>> x.sum(axis=1) # rows (second dimension)array([2, 4])>>> x[0, :].sum(), x[1, :].sum()(2, 4)
阅读全文
0 0
- python学习笔记(二)
- Python学习笔记(二)
- Python学习笔记(二)
- python学习笔记(二)
- Python学习笔记(二)
- python学习笔记(二)
- python学习笔记(二)
- Python学习笔记(二)
- python学习笔记(二)
- python学习笔记(二)
- Python学习笔记(二)
- python学习笔记:(二)
- Python学习笔记(二)
- Python学习笔记(二)
- Python学习笔记(二)
- python学习笔记(二)
- python学习笔记(二)
- Python学习笔记(二)
- 万能日志数据收集器 Fluentd
- day 17 vim介绍
- 二叉排序树的创建、插入和遍历(代码)
- OpenCV中的Mat函数
- python学习—Day17—类的重写,私有变量
- python学习笔记(二)
- 数据库多数据源配置
- Shuffle解密
- 11.7KNN
- gcc make和Makefile xshell基础
- 《七点三刻》,有价值的新闻早餐 2017年11月8日,星期三
- PHP四种基本排序算法
- Sorenson Capital:值得投资的 5 种 AI 技术
- python的iterator/iterable/generator