【发布时间】:2019-02-12 13:18:08
【问题描述】:
我有两个用同样的方法得到的列表,只有第一个是直接从列表中读取的,第二个是从postgresql中卸载的:
列表1
>>> print(type(list1))
... <class 'list'>
>>> print(list1)
... [array([-0.11152368, 0.1186936 , 0.00150046, -0.0174517 , -0.14383622,
0.04046987, -0.07069934, -0.09602138, 0.18125986, -0.14305925])]
>>> print(type(list1[0][0]))
... <class 'numpy.float64'>
列表2
>>> print(type(list2))
... <class 'tuple'>
>>> print(list2)
... (['-0.03803351', '0.07370875', '0.03514577', '-0.07568369', '-0.07438357'])
>>> list2 = list(list2)
>>> print(type(list2))
... <class 'list'>
>>> print(list2)
... [['-0.03803351', '0.07370875', '0.03514577', '-0.07568369', '-0.07438357']]
>>> print(type(list2[0][0]))
... <class 'str'>
如何查看元素的差异?如何从 list2 中获取 <class 'numpy.float64'> 之类的项目?
如果是numpy,为什么类型 list1 是类“列表”?
【问题讨论】:
-
你的代码告诉你到底有什么区别:第一个是一个包含 numpy float64s 数组的列表,第二个是一个包含字符串列表的元组。
-
如果它是 numpy,为什么类型 list1 是一个类“列表”? - 你在哪里看到的?
-
type(list1[0]) 是一个 numpy.array。
-
怎么样?,你有 cotes 那就意味着它是一个字符串
标签: python arrays python-3.x list