pytony格式化输出-占位符
1. %s s = string 字符串
2. %d d = digit 整数
3. %f f = float 浮点数
#!/usr/bin/env python #_*_coding:utf-8_*_ #date: 2018/1/13 #_author_="dingkai" name = input("your name:") age = input("your age:") if age.isdigit(): #像不像数字 int(age) else: print('age must be int!') exit(1) #退出程序 salary = input("your salary:") if salary.isdigit(): #像不像数字 int(salary) else: print('salary must be int!') exit(1) #退出程序 msg_info = ''' ------info of %s ------ name: %s age: %s salary: %s ------end------ ''' %(name,name,age,salary) print(msg_info)
【推荐】还在用 ECharts 开发大屏?试试这款永久免费的开源 BI 工具!
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步