Skip to main content
 首页 » 编程设计

python之在 Python 中计算阶乘

2025年05月04日13qlqwjy

计算时

math.factorial(100) 

我得到:

9332621544394415268169923885626670049071596826438162146859296389521759999322991560894146397615651828625369792082722378582601011 00000000000000000L

为什么数字末尾有一个L?

请您参考如下方法:

L 表示它是一个 long 而不是 int。您看到它的原因是您正在查看 long

的 repr

你可以使用

print math.factorial(100) 

或

str(math.factorial(100)) 

如果你只是想要数字