用户交互,格式化输出
用户交互
input(输入)
name = input('请输入你的名字:')
pwd = input('请输入你的密码:')
print(type(name))
print(type(pwd))
通过input输入的任何类型的值都会转变成数字串类型(str)
格式化输出
占位符
# %s
name = 'xiaoming'
age = 18
print('my name is %s ,my age is %s'%(name,age))
format格式化
name = 'xiaoming'
age = 18
print('my name is {},my age is {}'.format(name,age))
print('my name is {1},my age is {0}'.format(age,name))
f_String格式化
name = 'xiaoming'
age = 18
print(f'my name is {name},my age is {age}')
print(f'my name is {name},my age is {age+1}')
print(f'{age:.2f}')