python - 使用 Python 3.6.0 检索 Map() 值
问题描述
我查看了其他示例(例如Getting a map() to return a list in Python 3.x),但我无法弄清楚。我正在尝试打开这样的列表(大约有一千行,但我在这里简称它)
xyz = [' 0.35587716 -2.11974747 -3.69604539',
' 0.32428861 -2.15566737 -3.61313426',
' 0.35329223 -2.19372613 -3.75673156']
进入这样的数组或浮点数列表
b = [[0.35587716, -2.11974747, -3.69604539],
[0.32428861, -2.15566737, -3.61313426],
[0.35329223, -2.19372613, -3.75673156]]
我试过以下
b = np.array(map(lambda x: map(int, x.split()), xyz))
b = [[int(y) for y in x.split()] for x in xyz]
with open("file.log") as f:
lis=[map(int,line.split()) for line in f]
所有这些都给了我类似的东西:
<map object at 0x117a89390>
<map object at 0x117a89390>
<map object at 0x117a89390>
等等等等
但我不知道如何访问地图对象中的值。我正在使用 Python 3.6.0。我不知道该怎么办:(
解决方案
推荐阅读
- xslt-1.0 - XSL:遍历具有多个节点的节点并找到具有相同值的属性并将它们合并到一个单元格中
- css - 自动填充后设置禁用的输入背景颜色
- python - Pandas 聚合多列的值
- python - Numpy - 将双索引数组字符串表示形式转换为双索引数组
- php - 如何在 PHP 中使用 preg_match_all 从字符串返回 JavaScript?
- c# - 如何将 Jquery DataTables 添加到 asp.net 的 GridView
- firebase - Firebase 存储 REST API - 无效凭据(使用电子邮件/密码身份验证)
- python-3.x - 在 matplotlib 中使用 button_press_event 或 motion_notify_event 动态突出显示数据点
- javascript - 在没有 jQuery 的情况下更改滑块句柄颜色
- php - symfony 无法在 docker 上创建缓存目录