参考
tuple结构是不可以修改的,也不可以进行append,起初我以为和matlab中的cell 结构相似,结果emmm……
首次了解 tuple结构,是在 np.where()中返回的查询结果进行 type() 类型查看时候发现的。
例如:
np.where(data_t2 == Query) #查询data_t2这个dataframe中等于Query代表的字符串的位置。
#检索结果#(array([5914], dtype=int64), array([0], dtype=int64))
上述检索结果: (array([5914], dtype=int64), array([0], dtype=int64)) 当中,是一个 tuple元组,是一个里面包含了两个 array结构的 tuple元组。
type(np.where(data_t2 == Query)) #对np.where的反馈结果进行type() 命令查看类型#返回结果为#
继续向 tuple 里面查看
np.where(data_t2 ==Query)[0]#结果显示#array([5914], dtype=int64)
np.where(data_t2== Query)[1]#结果显示#array([0], dtype=int64)
type(np.where(data_t2== Query)[0]) #再使用type()对tuple元组内进行类型查看#结果显示#
【判断 tuple 里是否为空的方法?判断list是否为空?】
我采用了根据len() 函数的返回长度值确定是否为空,若空,则 len值 是0&