开发者

Leading and Trailing '0' gives error

random.randint(50,9)

or

random.randint(5,09)

give errors, although just

random.randint(5,9)

..works!

Leading and trailing zero's aren't allowed in python without conve开发者_JAVA技巧rting it to string or using x.f formatting?


oh, dear. "Trailing" zero gives error because first argument to randint should be smaller than the second.

Leading zeros are used to represent octal numbers in python-2.x as in many other languages.


A leading 0 means that the value is an octal literal, but 09 is not a valid octal number.


09 is not a valid dec integer in the second case and in the first case - you have to give the function the lower number first

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜