在python 3.8 SyntaxError中:解析时出现意外的EOF

问题描述 投票:0回答:1

使用简单的代码尝试计算pi(只是为了好玩)

import math
pi=0
for x in range (100000000000):
    pi = pi+((math.factorial(4*x)*(1103+26390*x))/((math.factorial(k)**4*396**(4*k)))

我在通过时收到SyntaxError:意外的EOf

 File "C:\Users\Marc\Desktop\programes amb python\calcular pi millor.py", line 5

                                                                                         ^
SyntaxError: unexpected EOF while parsing
[Finished in 0.9s]

我尝试了在本网络的其他问题中看到的所有内容,但似乎没有任何作用。

python python-3.x syntax-error eof python-3.8
1个回答
0
投票

您似乎在计算pi的公式的末尾错过了一个圆括号。而且您还没有为k分配任何值。我认为经过这2次更正后,代码应该可以正常运行。

© www.soinside.com 2019 - 2024. All rights reserved.