gpt4 book ai didi

python - 我如何从这个 block 中得到一些具体的东西?

转载 作者:行者123 更新时间:2023-11-28 22:13:08 25 4
gpt4 key购买 nike

所以我在一个列表类中有这个信息 block 。每当我执行 print(block) 时,它都会遍历整个列表并输出以下内容:

[{'version': 3, 'from': 'hx7ccc54932b913c71f7051e9dc1b621074c91d462', 'to': 'hxbf2a3504318b6315e38eeb87ee84402361a7d644', 'stepLimit': 1000000, 'timestamp': 1547599428802897, 'nid': 1, 'value': 30000000000000000000000, 'signature': 'ehslHJOj5e6apGhxEbZ6SESx5fagazIPNI5BjCo3sMYAGWVMQbiN8w/PH8BHhHmXBtwEGWiqEuTU5fa4toeOvwE=', 'txHash': '0x833bf64c224209ce850df8f9d47b9b6fcb1471cee93d8c946c2a2bfbded3fb2a'}]

我已经尝试执行 print(block[1]) 和 print(block[0][1]) 但它说超出范围?

from iconsdk.icon_service import IconService
from iconsdk.providers.http_provider import HTTPProvider

def main():
icon_service = IconService(HTTPProvider("https://ctz.solidwallet.io/api/v3"))
block = icon_service.get_block("latest")['confirmed_transaction_list']
print(block)


if __name__ == '__main__':
main()

我希望它给我 'to' (hxbf2a3504318b6315e38eeb87ee84402361a7d644) 的结果,而不是遍历整个 block ,即使我从未告诉程序这样做。

最佳答案

试试这个,获取 key 并打印它:

from iconsdk.icon_service import IconService
from iconsdk.providers.http_provider import HTTPProvider

def main():
icon_service = IconService(HTTPProvider("https://ctz.solidwallet.io/api/v3"))
block = icon_service.get_block("latest")['confirmed_transaction_list']
print(block[0]['to'])


if __name__ == '__main__':
main()

然后它会起作用。

关于python - 我如何从这个 block 中得到一些具体的东西?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54208967/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com