# 查看关键字的方法
import keyword # 引入关键字模块
# 打印出系统全部关键字
print(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']
# 定义变量age,把18放入age中
age = 18
print(age)
print(18)
# 给age1,age2,age3 放入同一个内容或者值
age1 = age2 = age3 = 18
print(age1)
print(age2)
print(age3)
# 一行内多个变量赋值
age4,age5,age6 = 12,21,45
print(age4)
print(age5)
print(age6)
18
18
18
18
18
12
21
45
# 声明的三种模式
# 格式1
s = 'i Love wangxiaojing'
print(s)
# 格式2
s2 =s1 = 'i love wangxiaojing'
# 格式三
s1,s2,s3 = 'i lover wangxiaojing', '我爱北京', '爱祖国,哎人民'
整数
浮点数
科学计算法
复数
# 二进制定义
a1 = 0b110
print(a1)
a2 = 0b11110
print(a2)
6
30
# 八进制的案例
a3 = 0o71
print(a3)
57
# 十六进制案例
a4 = 0xffff
print(a4)
a5 = 0x53f2
print(a5)
65535
21490
# 科学计数法
height = 184
print(height)
height = 1.84e2
print(height)
a = .2
print(a)
184
184.0
0.2
a = 4j
print(a)
4j
# 布尔值当作数字使用
age = 18 + True
print(age)
age = 18 + False
print(age)
# 判断语句
a = -1
if a:
print("负数市True")
else:
print("负数市False")
19
18
负数市True
# 字符串案例
love = 'I love wangxiaojing'
print(love)
love2 = "I love wangxiaojing"
print(love2)
# 三引号表示多行
love3= '''
wo
ai ni
zhongguo
'''
print(love3)
I love wangxiaojing
I love wangxiaojing
wo
ai ni
zhongguo