如何避免 Python 中的 L [英] How to avoid the L in Python

查看:37
本文介绍了如何避免 Python 中的 L的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<预><代码>>>>总和(范围(49999951,50000000))2449998775L

有没有办法避免数字末尾的L?

解决方案

L 只适合你.(所以你知道它是一个long)而且没有什么可担心的.

<预><代码>>>>a = sum(range(49999951,50000000))>>>一种2449998775L>>>打印一个2449998775

如您所见,打印的值(实际值)没有L,只有repr(表示)显示L

查阅这篇文章

>>> sum(range(49999951,50000000))
  2449998775L

Is there any possible way to avoid the L at the end of number?

解决方案

The L is just for you. (So you know its a long) And it is nothing to worry about.

>>> a = sum(range(49999951,50000000))
>>> a
2449998775L
>>> print a
2449998775

As you can see, the printed value (actual value) does not have the L it is only the repr (representation) that displays the L

Consult this post

这篇关于如何避免 Python 中的 L的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆