将浮点型,字符串转换成整型
print(int(1.1))
print(int('1'))
将整数,字符串转成浮点型
print(float(1))
print(float('1'))
将二进制,八进制,16进制转成10进制
print(int(0b1000))
print(int(0o1000))
print(int(0x1000))
将10进制转换成,二进制,八进制,16进制
print(bin(8))
print(oct(512))
print(hex(4096))
将字符串转换为字节
print(bytes("儿子", encoding="UTF-8"))
将字节转换成字符串
print(str(b'\xe5\x84\xbf\xe5\xad\x90', encoding="UTF-8"))
将ascii码转换为字符串
print(chr(100))
将字符串转换成ascii码
print(ord('d'))
2.条件控制语句
A: 86-100, B: 71-85, C: 61-70, D: 0-60
输入一个成绩打印出成绩的等级
score = 70
if 0 <= score <= 60:
print('D')
elif score <= 70:
print('C')
elif score <= 85:
print('B')
elif score <= 100:
print('A')