1、字面量
"hello"
5
4
2、注释
print("hello")
"""print("hello")
print("hello")
print("hello")"""
3、变量
money = 50
4、变量类型
print(type("haha"))
int_type = type(5)
print(int_type)
5、类型转换
6、标识符
7、运算符
加 减 乘 除 整除 取余 指数
+ - * / // % **
=
+= —= *= /= //= %= **=
8、字符串的拼接
name = "joe"
addr = "武汉市"
tel = 15940401498
print("我叫" + name, "我在" + addr, "我的电话是:" + tel)
9、格式化字符串
9.1 %s占位法
name = "潘桥"
age = 23.5
money = 10000
message = "我叫%s, 我的工资是%d, 我今年%f岁" % (name, money, age)
print(message)
9.2 f字符串
print(f"我是{name},年龄{age}")
print("1 + 1 = %d" % (1 + 1))
print("Python中字符串的类型是:%s" % type("aaa"))
print(f"Python中字符串的类型是:{type('aaa')}")
print(f"1 * 2 = {1 * 2}")
9.3 字符串精度控制
num1 = 20
num2 = 15.556
print("数字20, 宽度4, 结果是%4d" % num1)
print("数字15.556, 宽度8, 精度2, 结果是%8.2f" % num2)
10、input语句
name = input("请输入你的名字:")
password = input("请输入你的密码:")
print(f"你的名字是: {name}, 你的密码是: {password},你的密码类型是{type(password)}")