to get int literal attribute instead of syntaxerror, use a space or parenthesis. the int literal is a part if numeric literals in python. numeric literals also includes the following four different numerical types −
int (signed integers) − They are often called just integers or ints, are positive or negative whole numbers with no decimal point.
long (long integers ) − Also called longs, they are integers of unlimited size, written like integers and followed by an uppercase or lowercase L.
浮点数(浮点实数) - 也称为浮点数,它们表示实数,并且用小数点将整数部分和小数部分分隔开。浮点数也可以使用科学计数法表示,其中E或e表示10的幂次(2.5e2 = 2.5 x 102 = 250)。
complex (complex numbers) − are of the form a + bJ, where a and b are floats and J (or j) represents the square root of -1 (which is an imaginary number). The real part of the number is a, and the imaginary part is b. Complex numbers are not used much in Python programming.
立即学习“Python免费学习笔记(深入)”;
Let’s see why and what is the syntax error discussed in this question −
In this example, you can see we will get the invalid decimal literal syntax error −
print(5) print(5.__class__)
输出显示了一个语法错误
Let’s see how to fix it −
这是我们可以通过使用空格或括号来解决整数字面值错误的方法 -
print(5) print(5 .__class__) print((5).__class__)
5 <class 'int'> <class 'int'>
There’s another example as well −
a = 7 print(a) print(a .__class__) print((a).__class__)
7 <class 'int'> &t;class 'int'>
以上就是如何在Python中获取整数字面量属性而不是SyntaxError?的详细内容,更多请关注php中文网其它相关文章!
python怎么学习?python怎么入门?python在哪学?python怎么学才快?不用担心,这里为大家提供了python速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 //m.sbmmt.com/ All Rights Reserved | php.cn | 湘ICP备2023035733号