1.注释:
行首有一特殊标志符号运行时告知编程忽略此行;使代码更易于阅读。
例如:
#这是一个注释 print("hello world") #print() 方法用于打印输出,python中最常见的一个函数
输出结果为:
hello world
2.关键字:
编程语言中 具有特殊意义的词。
例如:
#使用keyword模块,可以输出当前版本的所有关键字import keyword#import() 函数用于动态加载类和函数 。如果一个模块经常变化就可以使用 import() 来动态载入。keyword.kwlist #在命令窗口中输出>>> import keyword>>> keyword.kwlist['false', 'none', 'true', 'and', 'as', 'assert', 'async', 'await', 'break', 'class', 'continue', 'def', 'del', 'elif', 'else', 'except', 'finally', 'for', 'from', 'global', 'if', 'import', 'in', 'is', 'lambda', 'nonlocal', 'not', 'or', 'pass', 'raise', 'return', 'try', 'while', 'with', 'yield']
3.数据类型:
将数据划分为不同的类别,数据所属的类别,即为数据类型。
标准数据类型
python3 中有六个标准的数据类型:
number(数字)
string(字符串)
list(列表)
tuple(元组)
set(集合)
dictionary(字典)
python3 的六个标准数据类型中:
不可变数据(3 个):number(数字)、string(字符串)、tuple(元组);
可变数据(3 个):list(列表)、dictionary(字典)、set(集合)。
4.对象:
python中具有3个属性的数据值——唯一标识,数据类型和值。
(例如:你要踢球,球就是一个对象,球的大小,颜色,价格就是球的属性。)
5.str(string):
字符串的数据类型。
例如:
#用type()查看数据类型a="abc"print(type(a),a)输出结果为:<class 'str'> abc
6.字符:
例如:a,b,c,,1,2,3等单个符号。
7.int(inetrger):
整数的数据类型。
例如:
a=1# a=int("123")print(type(a))输出结果:<class 'int'>
8.整型数据:
数据类型为int的对象,值为整数的数值。
例如:
a=1print(type(a))输出结果:<class 'int'>
相关推荐:《python视频教程》
9.float:
小数(带有小数点的数字)。
例如:
s=1.0 w=0.1 e=8.9 print(type(s)) print(type(w)) print(type(e)) 输出结果:<class 'float'><class 'float'><class 'float'>
10.浮点数:
数据类型为float的对象,值为小数的数值。
11.bool:
布尔值。
12.布尔值:
数据类型为bool的对象,值为true或false。
例如:
a=1b=2print(a>b)print(a<b) 输出结果:falsetrue
13.nonetype:
none对象的数据类型。
例如:
>>> print(type(none))<class 'nonetype'>>>>
14.none:
其值永远为none,用来表示数据缺失或者用于判断一个变量是否为空。它是nonetype的唯一值。
例如:
a=""b="123"c=34d=falsee=[]print(a==none)print(b==none)print(c==none)print(d==none)print(e==none)输出结果:falsefalsefalsefalsefalse
可知:从类型上来说,它也不等于空字符串,不等于空的列表,不等于false。
正确的判断方法为:
def fun(): #定义函数 return nonea = fun()if not a: print('t')else: print('f') if a is none: print('t') else: print('f')输出结果为:tt
15.常量:
永远不会改变的值。(包括数字、字符串、布尔值、空值 。例如,数字1的值永远是1)
例如:
#python内置常量['true'、'false'、'none'、'notimplemented'、'ellipsis'、'__debug__']
16.变量:
可以使用赋值符“=”来进行进行赋值操作的值,可以用来保存任何数据类型。
例如:
a=1,a是变量的名,1就是变量的值。
int qq=123b=0print(b)>>0x=100print(x)x=200print(x)>>100>>200
hi="你好"a="asd"print(a)print(hi)>>asd>>你好
注意:
1.变量名不能包含空格符。
2.变量名只能使用特定的字母,数字和下划线。
3.变量名不能以数字开头。
4.关键字不能作为变量名
#以下属于python内置函数,不能设为变量['and', 'as', 'assert', 'break', 'class', 'continue', 'def', 'del', 'elif', 'else', 'except', 'exec', 'finally', 'for', 'from', 'global', 'if', 'import', 'in', 'is', 'lambda', 'not', 'or', 'pass', 'print', 'raise', 'return', 'try', 'while', 'with', 'yield']
17.赋值操作符:
“=” ,给一个变量定义一个新值。
例如:
a="你好”print(a)输出结果:你好
18.增加:
增加一个变量的值。
例如:
a=1a=a+1print(a)>>2 或:x=1x+=1print(x)>>2
19.减少:
减少一个变量的值。
例如:
s=2s=s-1print(s)>>1或:x=1x-=1print(x)>>0
20.语法:
语言的规范,句子中字词顺序的一套规则及流程。
21.语法错误:
因违反语言的语法所导致的编程致命错误。
22.异常:
非致命的编程错误。
23.操作符:
在表达时与操作符一起使用的符号。
24.算数操作符:
数学表达式中的一类操作符。 如:加,减,乘,除
#偶数12%2>>0#奇数11%2>>1
25.操作数:
操作符两侧的值。
以上就是盘点python中的常用术语的详细内容。