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"{}"大括号里的内容一般都放变量 ...
随机推荐
- 个人第二次作业-c++实现四则运算生成器
c++实现四则运算生成器 GIT地址 Link Git用户名 Redwarx008 学号后五位 61128 博客地址 Link 作业链接 Link 环境配置 使用VS2019社区版,一键式安装,这里不 ...
- nodejs 遍历目录
1 var fs = require("fs"), path = require("path"); function walk(dir, callback) { ...
- Kettle整理
下载kettle版本 (1)hadoop version 查看hadoop的版本 hadoop2.6 (2)则在data-integration\plugins\pentaho-big-data ...
- 关于sass、scss、less的概念性知识汇总
这篇文章主要解答以下几个问题,供前端开发者的新手参考. 1.什么是Sass和Less? 2.为什么要使用CSS预处理器? 3.Sass和Less的比较 4.为什么选择使用Sass而不是Less? 什么 ...
- Spring Boot 2.x整合mybatis及druid数据源及逆向工程
1逆向工程 1)db.properties #============================# #===== Database sttings =====# #=============== ...
- POJ-1459-Pwoer Network(最大流Dinic, 神仙输入)
链接: https://vjudge.net/problem/POJ-1459 题意: A power network consists of nodes (power stations, consu ...
- 【leetcode】1170. Compare Strings by Frequency of the Smallest Character
题目如下: Let's define a function f(s) over a non-empty string s, which calculates the frequency of the ...
- DI,依赖注入,给对象赋值 ,get,set
DI,依赖注入,给对象赋值 ,get,set给对象赋值 2种方式:1.get.set默认无参构造方法给对象赋值 2.xml中有参构造器方法给对象赋值
- RedisTemplate访问Redis数据结构(二)——List
RedisTemplate使用ListOperations专门操作list列表.首先初始化spring工厂获得redisTemplate和opsForList private RedisTemplat ...
- SpringCloud 教程 (四) docker部署spring cloud项目
一.docker简介 Docker是一个开源的引擎,可以轻松的为任何应用创建一个轻量级的.可移植的.自给自足的容器.开发者在笔记本上编译测试通过的容器可以批量地在生产环境中部署,包括VMs(虚拟机). ...