关键字
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’]
格式化打印
name = 'isaac'
age = 18
height = 170.5
print('我的名字是%s,年龄是%d岁, 身高是%fcm' % (name, age, height))
print(f"我的名字是{name},年龄是{age}岁, 身高是{height}cm")
print('hello', end='_*_')
print('hello', end='A')
我的名字是isaac,年龄是18岁, 身高是170.500000cm 我的名字是isaac,年龄是18岁, 身高是170.5cm hello_*_helloA
输入
password = input('请输入密码:')
print('你输入的密码是 %s' % password)
请输入密码:123 你输入的密码是 123
变量转换
num1 = eval('100')
num2 = eval('3.14')
print(num1 , type(num1))
print(num2, type(num2))
100 <class ‘int’> 3.14 <class ‘float’>
|