![](https://img-blog.csdnimg.cn/20201014180756754.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
Python基础
随笔
学习有深度
这个作者很懒,什么都没留下…
展开
-
Python 一次读取多个输入值
a,b,c = input('enter a b c: ').split()输入1 2 3得到a=1 b=2 c=3原创 2020-08-12 12:50:24 · 1667 阅读 · 0 评论 -
Python np.repeat np.argmin np.arange用法(以牛客网某道经典题目为例)
import numpy as npa = np.repeat(np.arange(5).reshape([1, -1]), 5, axis=0) + 10.0print(a)[[10. 11. 12. 13. 14.] [10. 11. 12. 13. 14.] [10. 11. 12. 13. 14.] [10. 11. 12. 13. 14.] [10. 11. 12. 13. 14.]]np.repeat(axis=,x):使矩阵在某个axis上重复x次。np.arange.原创 2020-08-12 12:40:01 · 741 阅读 · 0 评论 -
Python numpy.arange()用法
生成一个指定起点终点和步长的列表,参数个数最多三个:分为一个参数,两个参数,三个参数三种情况1. 一个参数时,参数值为终点,起点取默认值0,步长取默认值1。import numpyprint(numpy.arange(5))[0 1 2 3 4]2. 两个参数时,第一个参数为起点,第二个参数为终点,步长取默认值1。包前不包后print(numpy.arange(5, 10))[5 6 7 8 9]3. 三个参数时,第一个参数为起点,第二个参数为终点,第三个参数为步长;原创 2020-08-12 11:17:18 · 22035 阅读 · 1 评论 -
Python numpy中reshape方法详解
作用:在不改变数据内容的情况下,改变一个数组的格式1. reshape(row,col)可以根据指定的数值将数据转换为特定的行数和列数r = np.random.randint(0, 10, size=(3, 4))print(r.reshape(3, 4))[[2 3 1 9] [4 5 5 0] [3 8 3 9]]reshape(3,4)----> 输出3行4列的矩阵2. reshape(1,-1) 是输出1行,不指定列数的矩阵;reshape(-1,1)则是输.原创 2020-08-12 11:09:10 · 11075 阅读 · 0 评论 -
Python 字典 items()方法
返回可遍历的(键, 值) 元组数组。a = {'first': '1', 'second': '2',}print(a.items())# a为键,b为值for a, b in a.items(): print("这是 a 输出的结果:" + a) print("这是 b 输出的结果:" + b)输出结果:...原创 2020-05-17 16:52:09 · 819 阅读 · 0 评论