我正在尝试熟悉uniswap-python模块,但在第一次测试时就已经被卡住了。这段代码来自getting started guide
from uniswap import Uniswap
address = None # or None if you're not going to make transactions
private_key = None # or None if you're not going to make transactions
version = 2 # specify which version of Uniswap to use
provider = "https://mainnet.infura.io/v3/c4bcdc3744df4340b875e095b0713258" # can also be set through the environment variable `PROVIDER`
uniswap = Uniswap(address=address, private_key=private_key, version=version, provider=provider)
# Some token addresses we'll be using later in this guide
eth = "0x0000000000000000000000000000000000000000"
bat = "0x0D8775F648430679A709E98d2b0Cb6250d2887EF"
dai = "0x6B175474E89094C44Da98b954EedeAC495271d0F"
uniswap.get_price_input(eth, dai, 10**18)我得到了这个错误:
Traceback (most recent call last):
File "c:\Users\phil\Desktop\Python\uniswap.py", line 1, in <module>
from uniswap import Uniswap
File "c:\Users\phil\Desktop\Python\uniswap.py", line 1, in <module>
from uniswap import Uniswap
ImportError: cannot import name 'Uniswap' from partially initialized module 'uniswap' (most likely due to a circular import) (c:\Users\phil\Desktop\Python\uniswap.py)发布于 2021-07-20 08:06:11
您的文件名为uniswap.py
c:\Users\phil\Desktop\Python\uniswap.py现在,from uniswap import ...加载您的文件,而不是模块uniswap。
只需重命名您的文件-即。test-uniswap.py。
c:\Users\phil\Desktop\Python\test-uniswap.pyhttps://stackoverflow.com/questions/68447649
复制相似问题