> ## Documentation Index
> Fetch the complete documentation index at: https://docs.tenderly.co/llms.txt
> Use this file to discover all available pages before exploring further.

# Web3.py - Node RPC 集成

> 了解如何使用 Web3.py 让您的 Python 应用通过 Node RPC 与 Ethereum 通信。

[web3.py](https://web3py.readthedocs.io/en/stable/index.html) 是用于与 Ethereum 交互的 Python 库。

它常见于去中心化应用（dapps）中，用于协助发送交易、与智能合约交互、读取区块数据以及各种其他用例。将 web3.py 指向 [Node RPC](/node-rpc/overview) 即可连接到 80+ EVM 网络，并参见 [JSON-RPC 参考](/node-rpc/rpc-reference) 以了解受支持的方法。

```py showLineNumbers title="connect.py" theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}

from web3 import Web3, AsyncWeb3

w3 = Web3(Web3.HTTPProvider('https:// mainnet.gateway.tenderly.co/<TENDERLY_NODE_ACCESS_KEY_MAINNET>'))
w3Async = AsyncWeb3(AsyncWeb3.AsyncHTTPProvider('https:// mainnet.gateway.tenderly.co/<TENDERLY_NODE_ACCESS_KEY_MAINNET>'))
w3Wss = Web3(Web3.WebsocketProvider('wss:// mainnet.gateway.tenderly.co/<TENDERLY_NODE_ACCESS_KEY_MAINNET>'))

print(w3.eth.get_block('latest'))
print(w3Async.eth.get_block('latest'))
print(w3Wss.is_connected())
print(w3Wss.eth.get_block('latest'))
```
