我如何解决 TypeError: pow() 需要 2 个参数(给出 3 个)?

sah*_*ndt 1 python rsa

我做了一个可以解决RSA数学题的小程序。程序的一部分检查是否需要密文,以及是否给出明文,e 和 n。

执行代码时,我收到一个错误:TypeError: pow() 需要 2 个参数(给定 3 个)即使 pow() 可以接受 3 个参数https://www.programiz.com/python-programming/methods/built-in /战俘

if "ciphertext" in NeededObjDict and "plaintext" in GivenObjDict and "e" in GivenObjDict and "n" in GivenObjDict:
        OutputCiphertext = str(pow(GivenPlaintext, GivenE, GivenN))
        print('ciphertext = ',OutputCiphertext)
Run Code Online (Sandbox Code Playgroud)

Wil*_*l C 5

我想我找到了你问题的原因。内置的pow功能有三个参数所看到这里。然而,math.pow函数有两个参数,因为看到这里

我会检查你是否powmath某个地方进口。