Connected to the target VM, address: '127.0.0.1:57711', transport: 'socket'
log4j:WARN No appenders could be found for logger (org.apache.http.client.protocol.RequestAddCookies).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.
我有一个numpy矩阵,我想用函数的结果填充它。此函数返回整数值的映射,该映射将映射到矩阵的一行中。
函数返回的值如下:
{1:6, 2:3, 3:2, 4:2, 5:1}
然后,我编写了以下代码来将值填充到矩阵中:
results = np.empty((10, 5), dtype=int)
for i in range(10):
result = method()
for j in range(5):
results[i, j] = result[j]
我想知道是否有一种更合适/更有效的方法来处理python?
我有一张名为catalogue的单子是这样送给我的:
[OrderedDict([(u'catalogue_id', 240)]), OrderedDict([(u'catalogue_id', 240)])]
我需要从上面创建一个新的ID列表。这就是我尝试过的:
x = [x.catalogue_id for x in catalogue]
但我知道错误是:
'OrderedDict' object has no attribute 'catalogue_id'.
我想这是因为这是一串白痴,这是怎么做到的?