1

有人遇到过这个吗?

import boto

conn = boto.dynamodb.connect_to_region('eu-west-1', aws_access_key_id=aws_key, aws_secret_access_key=aws_secret)
table = conn.get_table('TweetSample')

print table.scan(limit=1)

错误:

Traceback (most recent call last):
File "test.py", line 9, in <module>
print table.scan(limit=1)
File "table.py", line 518, in scan
return self.layer2.scan(self, *args, **kw)
TypeError: scan() got an unexpected keyword argument 'limit'
[Finished in 0.4s with exit code 1]

我也不知道...

4

1 回答 1

0

根据文档,(由返回的)scan方法不接受,但是。boto.dynamodb.table.Tableboto.dynamodb.layer2.Layer2.get_tablelimitmax_results

结果是生成器。所以,如果你想打印它,你应该迭代它:

import boto.dynamodb

conn = boto.dynamodb.connect_to_region(
    'eu-west-1',
    aws_access_key_id=aws_key,
    aws_secret_access_key=aws_secret)
table = conn.get_table('TweetSample')
for row in table.scan(max_results=1):
    print row

或将其转换为序列:

print list(table.scan(max_results=1))
于 2014-10-12T15:44:29.430 回答