Numpy教程(一)

article/2025/10/15 18:39:58

参考资料:清华计算机博士带你学-Python金融量化分析


目录

demo1-numpy与for循环对比

demo2-向量内(点)积求和(对应位置相乘)

demo3-ndarray常见属性

demo4-数组的创建

demo5-批量运算

demo6-索引与切片

demo7-布尔型索引

demo8-花式索引

demo9-取整

demo10-通用函数

demo11-Numpy统计方法

demo12-随机数生成

demo13-正态分布与均匀分布


demo1-numpy与for循环对比

import numpy as np
import random
#numpy是高性能计算和数据分析的基础包
#是pandas等其他工具的基础包
#ndarray 多维数组结构,高校且节省时间
#无需循环即可对整体进行操作
#线性代数、随机数、傅里叶变换等功#demo1-numpy与for循环对比
#numpy
value = np.array([random.uniform(100,200) for i in range(5)])
print(value)
newValue = value * 5  
print(newValue)
print("\n")#常规for循环
print(value)
newValue = []
for each in value:newValue.append(each*5)
print(newValue)

 

[114.7388318  164.09261949 111.88378219 123.49759661 141.26457631]
[573.69415901 820.46309746 559.41891096 617.48798305 706.32288156][114.7388318  164.09261949 111.88378219 123.49759661 141.26457631]
[573.6941590053353, 820.4630974561366, 559.4189109581303, 617.4879830450645, 706.3228815622876]

demo2-向量内(点)积求和(对应位置相乘)

price = np.array([random.uniform(10,20) for i in range(50)])
count = np.array([random.randint(1,10) for i in range(50)])print((price*count).sum())

 

3895.638762940498

demo3-ndarray常见属性

#demo3-ndarray常见属性#T 转置
#size 大小
#ndim 维度
#shape 维度大小 tuple
#dtype 类型print("*****一维*****")
value = np.array([random.uniform(100,200) for i in range(5)])  
print(value.dtype) #uniform浮点数
print(value.size)
print(value.ndim)
print(value.shape)print("*****二维*****")
value = np.array([[1,2,3],[4,5,6]])
print(value.dtype)
print(value.size)
print(value.ndim)
print(value.shape)print("*****三维*****")
value = np.array([[[1,2,3],[4,5,6]],[[7,8,9],[10,11,12]]])
print(value.dtype)
print(value.size)
print(value.ndim)
print(value.shape)value = np.array([[1,2,3],[4,5,6]])
print("转置前:")
print(value)
print("转置后:")
print(value.T)
*****一维*****
float64
5
1
(5,)
*****二维*****
int32
6
2
(2, 3)
*****三维*****
int32
12
3
(2, 2, 3)
转置前:
[[1 2 3][4 5 6]]
转置后:
[[1 4][2 5][3 6]]

demo4-数组的创建

#demo4-数组的创建print("*****array将列表转化为数组*****")
print(np.array(range(5)))
print(np.array([1,2,3,4]))
print(np.array([0]*10))print("*****ones zeros empty*****")
#ones zeros empty:据指定形状和类型创建数组
print(np.zeros(10))   #默认是浮点数,因为可能有除法运算
print(np.zeros(10,dtype="int"))   #默认是浮点数,因为可能有除法运算
print(np.ones(10))
print(np.empty(20)) #垃圾值/内存中之前存放的值,接触索引,并不会清空内存的值
print(np.ones((2,2))) #根据指定形状生成数组print("*****arange*****")
#arange numpy版的range 支持浮点数
print(np.arange(10))
print(np.arange(1,11,2)) #第三个参数为步长
print(np.arange(1,11,0.5)) #步长可以为小数!!!
# print(range(1,11,0.5))#报错print("*****linspace*****")
#linspace 类似range 但第三个数为数组长度 
print(np.linspace(0,10,11)) #0-10分为11个数字
print(len(np.linspace(0,10,11))) #linspace第三个参数为数组长度print("*****eye*****")
#单位矩阵
print(np.eye(2))print("linspace画图")
import matplotlib.pyplot as pltx = np.linspace(-10,10,100)
y = 5*x**3 + 3*x**2 + 2*x + 5
plt.plot(x,y)
*****array将列表转化为数组*****
[0 1 2 3 4]
[1 2 3 4]
[0 0 0 0 0 0 0 0 0 0]
*****ones zeros empty*****
[0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]
[0 0 0 0 0 0 0 0 0 0]
[1. 1. 1. 1. 1. 1. 1. 1. 1. 1.]
[0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]
[[1. 1.][1. 1.]]
*****arange*****
[0 1 2 3 4 5 6 7 8 9]
[1 3 5 7 9]
[ 1.   1.5  2.   2.5  3.   3.5  4.   4.5  5.   5.5  6.   6.5  7.   7.58.   8.5  9.   9.5 10.  10.5]
*****linspace*****
[ 0.  1.  2.  3.  4.  5.  6.  7.  8.  9. 10.]
11
*****eye*****
[[1. 0.][0. 1.]]
linspace画图

demo5-批量运算

#demo5-批量运算print("*****数组和标量运算*****")
test = np.arange(10)
print(test)
print(test+4)
print(test*2.5)
print(test/2)
print(test-10)print("*****数组和数组运算*****")
test1 = np.arange(10)
test2 = np.arange(10,20)
print(test1,test2,len(test1),len(test2))
print(test1+test2)  #对应位置做操作print("*****比较关系符*****")
print(test1<test2)
test1[1] = 999
print(test1<test2)print("*****reshape*****")
test = np.arange(15)
print(test.shape)
test = test.reshape((3,5))
print(test.shape)
*****数组和标量运算*****
[0 1 2 3 4 5 6 7 8 9]
[ 4  5  6  7  8  9 10 11 12 13]
[ 0.   2.5  5.   7.5 10.  12.5 15.  17.5 20.  22.5]
[0.  0.5 1.  1.5 2.  2.5 3.  3.5 4.  4.5]
[-10  -9  -8  -7  -6  -5  -4  -3  -2  -1]
*****数组和数组运算*****
[0 1 2 3 4 5 6 7 8 9] [10 11 12 13 14 15 16 17 18 19] 10 10
[10 12 14 16 18 20 22 24 26 28]
*****比较关系符*****
[ True  True  True  True  True  True  True  True  True  True]
[ True False  True  True  True  True  True  True  True  True]
*****reshape*****
(15,)
(3, 5)

demo6-索引与切片

#demo6-索引与切片print("*****二维数组的两种索引*****")
test = np.arange(15).reshape((3,5))
print(test)
print(test[2][1])
print(test[2,1])
print(test[2,2])print("*****list与array的切片差异*****")
testArray = np.arange(10)
testList = list(range(10))
print(testArray,testList)
print(testArray[4:],testList[4:])sliceArray = testArray[:4]  #浅拷贝/引用/数据量可能特别大,复制耗时占内存/默认是引用
sliceArrayCopy = testArray[:4].copy() #复制
sliceList = testList[:4]    #复制-深拷贝sliceArray[0] = 999
sliceList[0] = 666
sliceArrayCopy[-1] = 333print(sliceArray,sliceList)
print(testArray,testList)
print(sliceArrayCopy,testArray)print("*****二维数组的切片*****")
test = np.arange(15).reshape((3,5))
print(test)
#切0 1 5 6
print(test[:2,:2]) # 逗号{行,列}   对比:test[:2][:2]是错误切法,对比差异 
#切7 8 12 13
print(test[1:,2:4])
*****二维数组的两种索引*****
[[ 0  1  2  3  4][ 5  6  7  8  9][10 11 12 13 14]]
11
11
12
*****list与array的切片差异*****
[0 1 2 3 4 5 6 7 8 9] [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
[4 5 6 7 8 9] [4, 5, 6, 7, 8, 9]
[999   1   2   3] [666, 1, 2, 3]
[999   1   2   3   4   5   6   7   8   9] [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
[  0   1   2 333] [999   1   2   3   4   5   6   7   8   9]
*****二维数组的切片*****
[[ 0  1  2  3  4][ 5  6  7  8  9][10 11 12 13 14]]
[[0 1][5 6]]
[[ 7  8][12 13]]

demo7-布尔型索引

#demo7-布尔型索引print("*****选出数组中所有大于平均数的数*****")
#Q:选出数组中所有大于平均数的数
test = np.array([random.randint(0,20) for i in range(10)])
print(test,test.mean())
print(list(filter(lambda x:x>test.mean(),test))) #filter是惰性序列,需要使用List列表化
print(test[test>test.mean()])print(test>test.mean()) #打印[False False  True False  True  True  True False  True False]print("*****布尔型索引原理*****")
boolIndex = [False,False,True,False,True,True,True,False,True,False]
print(test[boolIndex]) #打印出值为True对应位置的数组值print("*****给定一个数组,选出数组中所有大于5的偶数*****")
#Q:给定一个数组,选出数组中所有大于5的偶数
test = np.array([random.randint(0,20) for i in range(10)])
print(test)
# print(test[test>5][test%2==0]) #第一次布尔型索引后长度已经变化
print(test[test%2==0][test[test%2==0]>5])
print(test[(test>5) & (test%2==0)])  #得加括号,因为位运算符优先级更高print(test[(test>5) | (test%2==0)])  #大于5或者为偶数print("*****逻辑与*****")
print(3 & 5) #011 101  001
print(bin(23))
print(bin(53))
#110101
#010111
#010101 -> 1+4+16
print(23 & 53)
*****选出数组中所有大于平均数的数*****
[ 8  5 11  4  9 12 17  6 19  3] 9.4
[11, 12, 17, 19]
[11 12 17 19]
[False False  True False False  True  True False  True False]
*****布尔型索引原理*****
[11  9 12 17 19]
*****给定一个数组,选出数组中所有大于5的偶数*****
[13 11 18  8  0  9 15  4 11  9]
[18  8]
[18  8]
[13 11 18  8  0  9 15  4 11  9]
*****逻辑与*****
1
0b10111
0b110101
21

demo8-花式索引

#demo8-花式索引print("*****一维数组,选出其中第1,3,5,6,7个元素*****")
#Q:对于一个数组,选出其中第1,3,5,6,7个元素,组成新的二维数组
test = np.arange(20)
print(test)
print(test[[1,3,5,6,7]])print("*****二维数组,花式索引*****")
test = np.arange(20).reshape(4,5)
print(test)
print(test[0,2:3]) #左边常规索引,右边切片
print(test[0,test[0]>2]) #左边常规索引,右边布尔型索引
print(test[0,test[0]>2]) #左边常规索引,右边布尔型索引print("*****二维数组索引两边不能同时为花式索引*****")
#选6 8 16 18
test = np.arange(20).reshape(4,5)
print(test)
print(test[[1,3],[1,3]]) #错误!!!print(test[[1,3],:][:,[1,3]]) #分开花式索引

 

*****一维数组,选出其中第1,3,5,6,7个元素*****
[ 0  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19]
[1 3 5 6 7]
*****二维数组,花式索引*****
[[ 0  1  2  3  4][ 5  6  7  8  9][10 11 12 13 14][15 16 17 18 19]]
[2]
[3 4]
[3 4]
*****二维数组索引两边不能同时为花式索引*****
[[ 0  1  2  3  4][ 5  6  7  8  9][10 11 12 13 14][15 16 17 18 19]]
[ 6 18]
[[ 6  8][16 18]]

demo9-取整

#demo9-取整print("*****1.6取整*****")
test = 1.6
test = np.array(test)
print(int(test)) #向0取整
print(np.floor(test)) #向下取整
print(np.ceil(test)) #向上取整
print(np.round(test)) print("*****-1.6取整*****")
test = -1.6
test = np.array(test)
print(int(test)) #向0取整
print(np.floor(test)) #向下取整
print(np.ceil(test)) #向上取整
print(np.round(test)) print("*****列表取整*****")
x = np.arange(-5.5,5.5)
print(x)
print(np.ceil(x)) #向上
print(np.floor(x))#向下
print(np.trunc(x))#截断 向0取整#round到两边距离相等时为偶数值!!!!
print("*****round到两边距离相等时为偶数值*****")
print(x)
print(np.round(x))
print(np.rint(x))  #rint与round一样
*****1.6取整*****
1
1.0
2.0
2.0
*****-1.6取整*****
-1
-2.0
-1.0
-2.0
*****列表取整*****
[-5.5 -4.5 -3.5 -2.5 -1.5 -0.5  0.5  1.5  2.5  3.5  4.5]
[-5. -4. -3. -2. -1. -0.  1.  2.  3.  4.  5.]
[-6. -5. -4. -3. -2. -1.  0.  1.  2.  3.  4.]
[-5. -4. -3. -2. -1. -0.  0.  1.  2.  3.  4.]
*****round到两边距离相等时为偶数值*****
[-5.5 -4.5 -3.5 -2.5 -1.5 -0.5  0.5  1.5  2.5  3.5  4.5]
[-6. -4. -4. -2. -2. -0.  0.  2.  2.  4.  4.]
[-6. -4. -4. -2. -2. -0.  0.  2.  2.  4.  4.]

demo10-通用函数

#demo10-通用函数
#通用函数:能同时对数组中所有元素进行运算的函数
#一元通用函数:abs sqrt exp log ceil floor rint trunc modf isnan isinf cos sin tan
#二元通用函数:add substract multiply divide power mod maximum minimumprint("*****abs sqrt modf....*****")
test = np.arange(-5.5,5.5)
print(test)
print(np.abs(test))
print(np.sqrt(test))
print(np.modf(test)) #整数与小数部分分开print("*****nan与inf*****")
print(5/test) #inf 无穷大,比任何一个数都大
print(np.sqrt(test)) #nan  not a number#nan与Inf是特殊的浮点数
print(np.nan == np.nan) 
print(np.nan is np.nan)print("*****删除数组中的nan*****")#判断inf同理
test = np.arange(5)
test = test/test
print(test)
print(np.isnan(test)) #判断nanprint(test[~np.isnan(test)]) #位反print("*****二元函数*****")
a = np.arange(3,8)
b = np.array([2,5,3,7,4])
print(a)
print(b)
print(np.maximum(a,b)) #比较取大
print(np.minimum(a,b))
print(np.mod(a,b)) #取模
print(np.power(a,b))
*****abs sqrt modf....*****
[-5.5 -4.5 -3.5 -2.5 -1.5 -0.5  0.5  1.5  2.5  3.5  4.5]
[5.5 4.5 3.5 2.5 1.5 0.5 0.5 1.5 2.5 3.5 4.5]
[       nan        nan        nan        nan        nan        nan0.70710678 1.22474487 1.58113883 1.87082869 2.12132034]
(array([-0.5, -0.5, -0.5, -0.5, -0.5, -0.5,  0.5,  0.5,  0.5,  0.5,  0.5]), array([-5., -4., -3., -2., -1., -0.,  0.,  1.,  2.,  3.,  4.]))
*****nan与inf*****
[ -0.90909091  -1.11111111  -1.42857143  -2.          -3.33333333-10.          10.           3.33333333   2.           1.428571431.11111111]
[       nan        nan        nan        nan        nan        nan0.70710678 1.22474487 1.58113883 1.87082869 2.12132034]
False
True
*****删除数组中的nan*****
[nan  1.  1.  1.  1.]
[ True False False False False]
[1. 1. 1. 1.]
*****二元函数*****
[3 4 5 6 7]
[2 5 3 7 4]
[3 5 5 7 7]
[2 4 3 6 4]
[1 4 2 6 3]
[     9   1024    125 279936   2401]

demo11-Numpy统计方法

#demo11-numpy统计方法test = np.arange(15)
print(test.sum())
print(test.mean())
print(test.std())
print(test.var())print("*"*20)
test = np.arange(0,10,0.2)
print(test)
print(test.mean())
print(test.std())
print(test.mean()-test.std(),test.mean()+test.std())
print(test.mean()-2*test.std(),test.mean()+2*test.std()) #2倍标准差 95.5%print(test.max(),test.min())
print(test.argmax(),test.argmin())
105
7.0
4.320493798938574
18.666666666666668
********************
[0.  0.2 0.4 0.6 0.8 1.  1.2 1.4 1.6 1.8 2.  2.2 2.4 2.6 2.8 3.  3.2 3.43.6 3.8 4.  4.2 4.4 4.6 4.8 5.  5.2 5.4 5.6 5.8 6.  6.2 6.4 6.6 6.8 7.7.2 7.4 7.6 7.8 8.  8.2 8.4 8.6 8.8 9.  9.2 9.4 9.6 9.8]
4.9
2.8861739379323628
2.0138260620676376 7.786173937932363
-0.8723478758647252 10.672347875864727
9.8 0.0
49 0

demo12-随机数生成

#demo12-numpy随机数生成print("*****random*****")
import random
print(random.random())       #0-1之间的数字
print(random.randint(0,10))  #[a,b]
print(random.choice([1,2,3,4,5]))
print(random.choice("hello world"))tempList = [2,3,5,6,3,432,5,6]
random.shuffle(tempList)
print(tempList)print("*****np.random*****") #指定数组长度或形状
print(np.random.randint(0,10,10))
print(np.random.randint(0,10,(3,5)))
print(np.random.rand(10)) #生成10个0-1的浮点数
print(np.random.uniform(0,10,10)) #生成10个0-10的浮点数  #均匀分布
print(np.random.choice([1,2,3,5,6,43,4],10))#随机出10个
*****random*****
0.6089449206423057
7
3
o
[3, 3, 6, 2, 6, 5, 432, 5]
*****np.random*****
[3 0 5 2 4 1 1 7 5 1]
[[9 2 4 1 1][1 4 6 3 8][0 8 9 8 7]]
[0.29993867 0.58133357 0.38837081 0.8073509  0.58386204 0.021214750.14208183 0.13526007 0.28158366 0.10912549]
[4.61452949 4.05137104 9.72873352 3.17844699 8.05749104 8.106775422.78802965 6.65677334 1.19002791 5.73758801]
[ 6  4  4  6  3  1  6  5  2 43]

demo13-正态分布与均匀分布

#demo13-正态分布与均匀分布testUniformList = np.random.uniform(-10,10,10000)#均匀分布
testNormList = np.random.randn(10000) #标准正态分布plt.hist(testUniformList,bins=20,density=True,edgecolor="white")
plt.show()plt.hist(testNormList,bins=20,density=True,edgecolor="white")
plt.show()

 


http://chatgpt.dhexx.cn/article/4AdknV5x.shtml

相关文章

NumPy进阶教程——超详细

Numpy基础教程&#xff1a; https://blog.csdn.net/qq_43328040/article/details/106601065 ———————————————————————————————————— 文章目录 一.ndarray对象内幕1.1 Numpy dtype 层次结构 二.高阶数组操作2.1重塑数组2.2 C顺序和Fortran…

Numpy安装教程

一、查看自己的python版本 使用winR弹出搜索框&#xff0c;输入cmd打开命令提示符&#xff0c;在其中输入python并按回车&#xff0c;得到以下结果 查看自己使用的python版本 二、下载对应的Numpy版本 Python Extension Packages for Windows - Christoph Gohlke (uci.edu) 可…

Python Numpy库教程(超详细)

1 Numpy概述 1.1 概念 Python本身含有列表和数组&#xff0c;但对于大数据来说&#xff0c;这些结构是有很多不足的。由于列表的元素可以是任何对象&#xff0c;因此列表中所保存的是对象的指针。对于数值运算来说这种 结构比较浪费内存和CPU资源。至于数组对象&#xff0c;它…

Python基础(十) | Numpy详细教程

⭐本专栏旨在对Python的基础语法进行详解&#xff0c;精炼地总结语法中的重点&#xff0c;详解难点&#xff0c;面向零基础及入门的学习者&#xff0c;通过专栏的学习可以熟练掌握python编程&#xff0c;同时为后续的数据分析&#xff0c;机器学习及深度学习的代码能力打下坚实…

【python学习】最全Numpy教程

1. Numpy概述 NumPy&#xff08;Numerical Python的简称&#xff09;是Python数值计算最重要的基础包。大多数提供科学计算的包都是用NumPy的数组作为构建基础。1.1.1. Why NumPy? 1.一个强大的N维数组对象ndarray&#xff0c;具有矢量算术运算和复杂广播能力的快速且节省空…

Python Numpy库教程

目录 1 Numpy概述1.1 概念1.2 功能1.3 对象1.4 数据类型1.5 数组属性 2 Numpy数组操作2.1 Numpy创建2.1.1 利用列表生成数组2.1.2 利用random模块生成数组2.1.3 创建特定形状数组 2.2 索引和切片2.2.1 元素表示2.2.2 切片表示2.2.3 多维数组的切片2.2.4 布尔索引2.2.5 元素查找…

【数据分析】Numpy入门教程(超详细)

Numpy 教程 什么是Numpy&#xff1f;Numpy(Numerical Python)是一个Python扩展库&#xff0c;支持大量的维度数组和矩阵运算&#xff0c;此外也针对数组运算提供大量的数学函数库。 其主要用于数组计算&#xff0c;特点包括&#xff1a; 一个强大的N维数组对象ndarray广播功…

Python之Numpy详细教程

NumPy - 简介 NumPy 是一个 Python 包。 它代表 “Numeric Python”。 它是一个由多维数组对象和用于处理数组的例程集合组成的库。 Numeric&#xff0c;即 NumPy 的前身&#xff0c;是由 Jim Hugunin 开发的。 也开发了另一个包 Numarray &#xff0c;它拥有一些额外的功能。…

Java泛型方法的定义和使用

目录 一、基本介绍1、Java泛型的基本语法格式为:2、在使用泛型时,还需要注意以下几点:二、泛型的优点1、类型安全2、消除强制类型转换3、更高的效率4、潜在的性能收益三、常见泛型字母含义四、使用泛型时的注意事项五、泛型的使用1、泛型类2、泛型接口3、泛型通配符4、泛型方…

java参数传入泛型类型_java泛型方法参数传递

Java参数&#xff0c;不管是原始类型还是引用类型&#xff0c;传递的都是副本(有另外一种说法是传值&#xff0c;但是说传副本更好理解吧&#xff0c;传值通常是相对传址而言)。 如果参数类型是原始类型&#xff0c;那么传过来的就是这个参数的一个副本&#xff0c;也就是这个…

Java 泛型作为方法参数

Java 泛型作为方法参数 例程源码&#xff1a; import java.util.List;public class GoodsSeller {public void sellGoods(List<? extends Goods> goods){//调用集合中的sell方法for(Goods g:goods){g.sell();}} }public class Book extends Goods {Overridepublic void …

49天精通Java,第32天,Java泛型方法的定义和使用

🏆作者简介:哪吒,CSDN2022博客之星Top1、CSDN2021博客之星Top2、多届新星计划导师✌、博客专家💪 ,专注Java硬核干货分享,立志做到Java赛道全网Top N。 🏆本文收录于Java基础教程(入门篇),包含面向对象、基本数据类型、数组、继承和多态、泛型、枚举等Java基础知识…

java泛型 方法返回值带有泛型 <T>

方法返回值前的<T>的左右是告诉编译器&#xff0c;当前的方法的值传入类型可以和类初始化的泛型类不同&#xff0c;也就是该方法的泛型类可以自定义&#xff0c;不需要跟类初始化的泛型类相同。 转自&#xff1a;https://blog.csdn.net/huyashangding/article/details/9…

Java 泛型方法/接口、泛型限定

文章目录一、为什么要定义泛型方法1、从泛型类到泛型方法的演变过程2、定义泛型方法的好处二、创建一个泛型方法格式常用的形式三、泛型接口1、格式2、例子四、类型通配符(泛型的高级应用)1、什么是通配符 (?)2、类型通配符上限定(? extends T >可以接收T类型或者T的子类型…

Java 泛型方法

本文包含&#xff1a; 定义泛型方法泛型方法和类型通配符的区别Java 7 的“菱形”语法与泛型构造器设定通配符下限泛型方法与方法重载Java 8 改进的类型推断 1. 定义泛型方法 假设需要实现这样一个方法&#xff1a;该方法负责将一个 Object 数组的所有元素添加到一个 Collec…

【java】泛型方法的定义

一、定义泛型方法的格式 二、调用泛型方法的语法格式 三、解释 1、定义泛型方法时&#xff0c;必须在返回值前边加一个<T>&#xff0c;来声明这是一个泛型方法&#xff0c;持有一个泛型T&#xff0c;然后才可以用泛型T作为方法的返回值。 2、Class<T>的作用就是指…

Java 中的泛型(两万字超全详解)

文章目录 前言一、泛型概述1. 什么是泛型&#xff1f;为什么要使用泛型&#xff1f;2. 泛型使用场景3. 泛型概述小结 二、泛型类1. 泛型类的定义2. 泛型类的使用 三、泛型接口四、泛型方法1. 泛型方法的定义2. 泛型方法的使用3. 泛型方法中的类型推断 五、类型擦除1. 什么是类型…

Java中的泛型方法

泛型是什么意思在这就不多说了&#xff0c;而Java中泛型类的定义也比较简单&#xff0c;例如&#xff1a;public class Test{}。这样就定义了一个泛型类Test&#xff0c;在实例化该类时&#xff0c;必须指明泛型T的具体类型&#xff0c;例如&#xff1a;Test t new Test();&am…

【软件测试】使用C++ Test进行动态测试

测试目的 1.掌握动态测试的方法。 2.掌握使用Parasoft C Test进行动态测试。 测试环境 Windows XP, Parasoft C Test 9.2 测试内容 使用Parasoft C Test进行动态测试&#xff0c;包括自动化测试、自定义测试用例、数据源测试用例、桩函数机制。 测试过程及结果 4.1 基于…

测试基础-动态白盒测试

1.动态白盒测试 定义&#xff1a;也称结构化测试。利用查看代码功能&#xff08;作什么&#xff09;和实现方式&#xff08;怎么做&#xff09;得到的信息来确定哪些需要测试、哪些不需要测试、如何开展测试。 动态白盒测试包括以下4个部分&#xff1a; 直接测试底层函数、过…