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)
pytony格式化输出-占位符的更多相关文章
- 第四天,for循环,格式化输出,占位符,pycharm安装.列表处理
字符格式化输出 占位符 %s s = string %d d = digit 整数 %f f = float 浮点数,约等于小数 列表,元组 查 索引(下标) ,都是从0开始 切片 .count 查某 ...
- c语言基础:各种数据类型的输出占位符
c语言中的输出操作相对java来说是比较麻烦的,每种数据类型的输出都有各自的占位符: 下面是各种数据类型的输出占位符: short/int : %d ; printf("这个整数是:%d&q ...
- python基础知识梳理----2格式化输出,替换符
一:格式化输出 1: 格式: 例子: name=input('请输入name') print('名字是%s'%name) %s就是代表字符串串占位符,除此之外,还有%d, 是数字占位符, 如果把上⾯面 ...
- C语言printf格式化输出修饰符详解
转换说明 输出 %a,%A 浮点数.十六进制数和p-计数法(C99) %c 一个字符 %d 有符号十进制数 %e,%E 浮点数,e计数法 %f 浮点数,十进制计数法 %g,%G 根据数值不同自动选择% ...
- 319 Python基础之格式化输出、逻辑运算符、编码、in not in、while else、
一.格式化输出 占位符%,字符串占位符%s,数字占位符%d 第一种name = input('姓名') age = input('年龄') hobby = input ("爱好") ...
- python - 字符串的格式化输出
# -*- coding:utf-8 -*- '''@project: jiaxy@author: Jimmy@file: study_2_str.py@ide: PyCharm Community ...
- day06-1 与用户交互以及格式化输出
目录 Python的与用户交互 Python2的input和raw_input(了解) 格式化输出 占位符 format函数格式化字符串 f-string格式化(方便) Python的与用户交互 in ...
- Day 04 [与用户交互,格式化输出,基本运算符]
Python 的与用户交互 name=input("请输入姓名:") height=input('请输入身高:') weight=input('请输入体重:') 在python3中 ...
- 字符串格式化输出、while循环、运算符、编码
1.字符串格式化输出 %占位符: %s => 字符串 %d=>整数型 %%=>转义 普通的% %()不能多,不能少,一一对应 f"{}"大括号里的内容一般都放变量 ...
随机推荐
- Codeforces Round #430 (Div. 2) - D
题目链接:http://codeforces.com/contest/842/problem/D 题意:定义Mex为一个序列中最小的未出现的正整数,给定一个长度为n的序列,然后有m个询问,每个询问给定 ...
- 牛客练习赛33 E tokitsukaze and Similar String (字符串哈希hash)
链接:https://ac.nowcoder.com/acm/contest/308/E 来源:牛客网 tokitsukaze and Similar String 时间限制:C/C++ 2秒,其他语 ...
- macOS安装wget
brew install wget 或者 curl -O http://ftp.gnu.org/gnu/wget/wget-1.13.4.tar.gz tar xzvf wget-1.13.4.tar ...
- snmpwalk工具使用
snmpwalk是SNMP的一个工具,它使用SNMP的GETNEXT请求查询指定OID(SNMP协议中的对象标识)入口的所有OID树信息,并显示给用户. 在linux下使用snmpwalk工具,我们 ...
- DevExpress v19.1新版亮点——WinForms篇(一)
行业领先的.NET界面控件DevExpress v19.1终于正式发布,本站将以连载的形式介绍各版本新增内容.在本系列文章中将为大家介绍DevExpress WinForms v19.1中新增的一些控 ...
- Delphi-----接口请求,Get与Post
unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms ...
- HTML中表格table标签的实例
一.表格有边框,第一行居中对齐 二.表格没有边框 三.表格有水平标题 四.表格有垂直标题 五.合并行单元格 colspan合并单元格 六.表格有单元格边距(内边距) 七.表格没有单元格间距 八.表格有 ...
- CodeForces 1198C 1199E Matching vs Independent Set
Time limit 1000 ms Memory limit 262144 kB 这题是一场cf里,div1的第三题,div2的第5题 中文题意 给一张无向图,没说连通性,要你选出一个大小为n的匹配 ...
- (17)Python读取摄像头并实现视频播放、暂停、指定目录保存、回放功能
读取摄像头并播放.暂停功能 import sys #import scipy.io as sio from PyQt5 import QtGui, QtCore, QtWidgets #from wy ...
- (8)Linux(客户端)和Windows(服务端)下socket通信实例
Linux(客户端)和Windows(服务端)下socket通信实例: (1)首先是Windows做客户端,Linux做服务端的程序 Windows Client端 #include <st ...