如果我有这样的输入:
a = np.array([['31-01-2017 15:02:13.870916 120 0.3'],
['31-01-2017 15:02:15.890922 100 0.5'],
....])
有没有办法访问这些信息?
例如,第一个是时间戳,第二个是值(120),第三个是值(0.3)
答案 0 :(得分:2)
不确定。从' '
右侧拆分,最大拆分等于2。
import numpy as np
a = np.array([['31-01-2017 15:02:13.870916 120 0.3'],
['31-01-2017 15:02:15.890922 100 0.5'],
])
print a[0][0].rsplit(' ', 2)
输出:
['31-01-2017 15:02:13.870916', '120', '0.3']
l = [['31-01-2017 15:02:13.870916 120 0.3'], ['31-01-2017 15:02:15.890922 100 0.5'] ]
print [a[0].rsplit(' ', 2) for a in l]
输出:
[['31-01-2017 15:02:13.870916', '120', '0.3'], ['31-01-2017 15:02:15.890922', '100', '0.5']]