Python--格式化输出%s和%d,你知道嘛????(初学者必看~~~)

python入门5.格式化符号和意义%s %d %f 格式化符号 转换 %s 字符串 %d 有符号的十进制数 %f 浮点数 %c 字符 %u ... 阅读详情

Python---格式化输出%S%d

 pythn print格式化输出。

%r 用来做 debug 比较好,因为它会显示变量的原始数据(raw data),而其它的符
号则是用来向用户显示输出的。 

 

1. 打印字符串

print ("His name is %s"%("Aviad"))

效果:

2.打印整数

print ("He is %d years old"%(25))

效果:

3.打印浮点数

print ("His height is %f m"%(1.83))

效果:

4.打印浮点数(指定保留小数点位数)

print ("His height is %.2f m"%(1.83))

效果:

5.指定占位符宽度

print ("Name:%10s Age:%8d Height:%8.2f"%("Aviad",25,1.83))

效果:

6.指定占位符宽度(左对齐)

print ("Name:%-10s Age:%-8d Height:%-8.2f"%("Aviad",25,1.83))

效果:

7.指定占位符(只能用0当占位符?)

print ("Name:%-10s Age:%08d Height:%08.2f"%("Aviad",25,1.83))

效果:

8.科学计数法

format(0.0015,'.2e')

效果:

 

我们还可以用词典来传递真实值。如下:
print ("I'm %(c)s. I have %(l)d yuan." % {'c':'hungry','l':22})
调试输出:
I'm hungry. I have 22 yuan.


格式符

免费领取Python自动化学习资料  工具,面试宝典面试技巧,加QQ群,785128166,群内还会大佬技术交流

格式符为真实值预留位置,并控制显示的格式。格式符可以包含有一个类型码,用以控制显示的类型,如下:

%s    字符串 (采用str()的显示)

%r    字符串 (采用repr()的显示)

%c    单个字符

%b    二进制整数

%d    十进制整数

%i    十进制整数

%o    八进制整数

%x    十六进制整数

%e    指数 (基底写为e)

%E    指数 (基底写为E)

%f    浮点数

%F    浮点数,与上相同

%g    指数(e)或浮点数 (根据显示长度)

%G    指数(E)或浮点数 (根据显示长度)

 

%%    字符"%"

 

可以用如下的方式,对格式进行进一步的控制:

%[(name)][flags][width].[precision]typecode

(name)为命名

flags可以有+,-,' '或0。+表示右对齐。-表示左对齐。' '为一个空格,表示在正数的左侧填充一个空格,从而与负数对齐。0表示使用0填充。

width表示显示宽度

precision表示小数点后精度

 

比如:

print("%+10x" % 10)
print("%04d" % 5)
print("%6.3f" % 2.3)

 

上面的width, precision为两个整数。我们可以利用*,来动态代入这两个量。比如:

print("%.*f" % (4, 1.2))

Python实际上用4来替换*。所以实际的模板为"%.4f"。

 

总结

Python中内置的%操作符可用于格式化字符串操作,控制字符串的呈现格式。Python中还有其他的格式化字符串的方式,但%操作符的使用是最方便的。

MAPPO实战:从理论到代码的协作智能体训练指南 本文详细介绍了MAPPO算法在多智能体协作训练中的实战应用,从理论基础到代码实现全面解析。通过对比PPO与MAPPO的差异,深入讲解CTDE框架、网络架构设计、参数调优等关键环节,并提供实际项目中的调参经验和常见问题解决方案,帮助开发者快速掌握这一强化学习前沿技术。 阅读详情

相关推荐

懒人精灵手游内存技术分析

教学声明:全套教程教学用到的游戏采用手游私服网游进行测试,不针对任何游戏。教学只做计算机技术研究,不做其他用途。

yizhihaoren123的博客 1662

Python格式化输出(%d、%f、占为符及百分号)

一、python格式化输出 使用占位符输出时,%s表示字符串输出,%d表示整数输出,%f表示浮点数输出 优点:填充方式灵活,单个参数可以多次输出,参数顺序可以不同 1、整型 %d 表示整型 >>>name = 'lly' >>>age = 19 >>>print('%s的年龄是%d' %(name,age)) 2、浮点型 %f表示浮点型...

CapejasmineY的博客 1万+

告别双系统!用Ventoy把Ubuntu 22.04装进U盘,打造你的随身开发环境(附保姆级避坑指南)

本文详细介绍了如何使用Ventoy将Ubuntu 22.04安装到U盘,打造便携式开发环境。通过即插即用的特性,开发者可以在任何x86电脑上快速启动完整的Ubuntu系统,无需配置双系统或虚拟机。文章提供了从硬件准备到系统优化的全流程指南,帮助用户高效创建随身开发环境。

weixin_31569671的博客 368

Python中关于%d

输出字符串时,可以依据变量的值,自动更新字符串的内容。#%05d意思是打印结果为5位整数,当整数的位数不够5位时,在整数左侧补0,所以%05d的打印结果是00014。#%-3d意思是打印结果为3位整数,当整数的位数不够3位时,在整数右侧补空格,所以%3d的打印结果是14_#%3d意思是打印结果为3位整数,当整数的位数不够3位时,在整数左侧补空格,所以%3d的打印结果是 14。#%1d意思是打印结果为1位整数,当整数的位数超过1位时,按整数原值打印,所以%1d的打印结果还是14。#%d打印时结果是14。

m0_74367038的博客 5531

JeecgBoot漏洞利用工具解析:一键getshell原理与安全加固实践

在应用安全领域,远程代码执行(RCE)和文件上传漏洞是Web系统面临的高危威胁,其核心原理在于对用户输入的控制不足或安全校验缺失。攻击者通过构造恶意请求,可绕过系统边界,在服务器上执行任意命令或上传恶意文件,从而获取系统控制权。这类漏洞的技术价值在于揭示了应用层安全防护的薄弱环节,其利用方式自动化、集成化趋势明显,极大地提升了攻击效率。在低代码开发平台等快速构建的业务系统中,此类风险尤为突出。应用场景广泛覆盖安全测试、渗透评估与应急响应。本文聚焦于JeecgBoot平台的历史高危漏洞,深入解析其SQL注入、

weixin_30787531的博客 555

Abaqus数据导出技巧:轻松处理大量XY数据

通过上述三种方法,我们可以解决Abaqus中大量XY数据导出的问题。无论是使用插件、编写Python脚本,还是利用Abaqus的内置报告功能,都可以帮助我们高效地处理数据。希望这篇博客能够帮助到你,提高你在Abaqus使用过程中的数据处理效率。

m0_62153576的博客 1921

输出控制符%s、%d、%x、%f

因为计算机中所有的数据都是二进制 0、1 代码,所以输出的时候要用“输出控制符”告诉计算机以什么形式将二进制数据显示出来。

zz2230633069的博客 4135

轴承故障诊断领域的论文到底有多水

这个是最让人困惑的,就好像你说自己证明了某个方法更好,但是你却没有交代自己怎么做的,或者说你交代的过程有外行话或者逻辑上的缺陷,但是你就这么给出个结果完事了。由于自己没有足够大的学术交流圈子,为了尽量避免误判,我在原来13篇论文的基础上又读了18篇,这些论文至少都出自中文核心,有一些还有EI的title,事实上近几年能找到的文章也不算多,这些基本能说明问题了。当然,还有更多细节,比如说损失函数你得交代吧,模型超参数得介绍全吧,至少数据集是哪个工况下的得说吧,当你想复现这些论文,关注点在这些地方的时候。

weixin_50642818的博客 3058

Python 格式化输出 %d、%s、%f ... 的使用

%d、%s、%f... 这些以 % 开头的占位符都是为了支持 python 字符串格式化输出。 举几个例子 >>> name = "abc" >>> print("%s def"%name) abc def >>> name = '''%(char)s def''' >>> print(name % {'char': 'abc'}) abc def 常见的格式化符号(%s 与 %(key)s 只是使用场景不一样..

卡尔特斯 4810

面向高分辨率遥感影像的建筑物有效分割方法:基于UNFormer的全局与局部结构特征建模

基于UNFormer的建筑物遥感图像语义分割模型实现 摘要:本文介绍了一种结合CNN与Transformer优势的UNFormer模型,用于解决建筑物遥感图像语义分割任务。该模型采用U形结构设计,编码器基于CNN提取局部特征,瓶颈层使用Transformer捕捉全局依赖关系,解码器通过上采样融合多尺度特征。实验在WHU建筑物数据集上进行,可视化结果显示模型能有效处理建筑物密集区域和复杂边缘。文章提供了从环境搭建、数据处理到模型实现的完整教程,包括PyTorch代码实现细节,帮助读者快速复现这一先进的语义分割

m0_71589036的博客 5370

手把手实现STM32+ESP8266+原子云服务器+手机APP应用——第三节-编写STM32程序实现STM32+ESP8266+原子云服务器+手机APP互相通信—远程数据传输及控制灯

接上一篇,本节使用原子云服务器。编写STM32程序实现STM32+ESP8266+原子云服务器+手机APP互相通信—远程数据传输及控制灯。使用的硬件包括:STM32F103(任意其他款系列也可以的)、正点原子ATK-ESP8266、LED灯。实现编写STM32程序代码来传输单片机数据到原子云服务器和手机APP进行显示,同时通过手机APP和原子云服务器可以远程控制单片机,例如本节实现远程点/灭灯,以此可以扩展开发更多的功能。本专栏本系列的相关文章可查看下面链接:

嵌入式阿齐Archie 8422

Python占位符 %d %s %f %r的使用

python 占位符介绍

qq_36297093的博客 1万+

Codex 100个真实案例 - 用AI自动生成API测试用例(接口测试全覆盖)

API 测试是保障后端质量的关键环节,但手写测试用例既枯燥又容易遗漏。本案例将展示如何用 Codex 从 Swagger/OpenAPI 规范文档自动生成 pytest 测试用例——包括正常流程测试、边界值测试、异常参数测试、性能压力测试,还能自动生成 Mock 数据和精美的 HTML 测试报告。全程自然语言驱动,让 API 测试覆盖率从 0 飙到 90%+!

yueyeguzhuo的专栏 278

Python %d,%s,%f

当你看到输出语句存在%d,%s,%f等百分号的时候,就接触到python字符串格式化输出相关知识。 Python 支持字符串格式化输出,尽管这样可能遇到非常复杂的表达式,但最基本的是用法就是将一个值插入到一个有字符串格式符%s的字符串中。如,例1: name = '阿昌' print("大家好,我叫%s"%name) 输出 大家好,我叫阿昌 在程序中,看到%s这样的操作符,这就是p...

全村的希望的博客 12万+

最新的sdio 4.0 spec 协议标准 带书签 高清完整PDF版

Part-E1-SDIO-Specification-Ver4.00-Final-120220.pdf:最新的sdio 4.0 spec 协议标准 带书签 高清完整PDF版,包括SDIO 接口的外设,SDIO 接口官方协议等。

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

Python中%s、%d、%f意义及用法详解

%s: string="hello" #%s打印时结果是hello print "string=%s" % string # output: string=hello #%2s意思是字符串长度为2,当原字符串的长度超过2时,按原长度打印,所以%2s的打印结果还是hello print "string=%2s" % string # output: st...

树先生的博客 3万+

OV9734 DATASHEET,完整规格书

OV9734完整规格书,包括电气参数,尺寸规格,寄存器配置表等

Python格式化字符 %s %d %f %g实例讲解

Python格式化字符 %s %d %f %g实例讲解 格式 描述 %% 百分号标记 #就是输出一个% %c 字符及其ASCII码 %s 字符串 %d 有符号整数(十进制) %u 无符号整数(十进制) %o 无符号整数(八进制) %x 无符号整数(十六进制) %X 无符号整数(十六进制大写字符) %e 浮点数字(科学计数法) %E 浮点数字(科学计数法,用E代替e) ...

python深度学习笔记,一起学习的加QQ2737499951 2万+

SAP B1中文培訓教材_SDK

公司内部培训资料,对开发工具 ,DIAPI, UIAPI,Add-ON有详细解说

【Python】一文向您详细介绍格式化字符串中 %s、%d、%f 的用法

🔥【Python】掌握字符串格式化魔法,让你的代码会说话!💬 还在为字符串格式化犯愁吗?本文带你解锁Python中`%s`、`%d`、`%f`的神奇用法!从基础到进阶,从字符串到浮点数,应有尽有。我们还教你如何自定义格式、处理字典数据,更有`str.format()`方法的独家揭秘!读完本文,你将轻松驾驭Python字符串格式化,让代码更优雅、更可读!#Python字符串格式化 #%s #%d #%f #str.format()

创作高质量博文,分享知识,共同进步! 4863

Python字符串格式化深度解析:占位符%s、%d等的详细用法

在 Python 中,字符串格式化是一个非常常见的操作。它让我们可以通过模板来创建字符串。其中,%s%d等是在字符串格式化中经常使用的语法,分别表示字符串和整数的占位符。

AI悦创·编程私教1v1 2万+

Python格式化输出 %s %d %f

格式 描述 %% 百分号标记 #就是输出一个% %c 字符及其ASCII码 %s 字符串 %d 有符号整数(十进制) %u 无符号整数(十进制) %o 无符号整数(八进制) %x 无符号整数(十六进制) %X 无符号整数(十六进制大写字符) %e 浮点数字(科学计数法) %E 浮点数字(科学计数法,用E代替e) %f 浮点数字(用小数点符号) %g

Hey_cancan的博客 8万+

python 字符串格式化输出 %d,%s及 format函数, 数字百分化输出

旧式格式化方式:%s,%d 1、顺序填入格式化内容 s = "hello %s, hello %d"%("world", 100) print(s)<br> 结果: 'hello world, hello 100' 2、使用关键字参数 s= "%(name)s age %(age)d"%{"name":"Tom", "age":10}<br>print(s) 结果:Tom...

python学习者的博客 3945

python %s %d %f 通配符及format学习

一、%s:代表string 字符串 print ("today is %s" %“星期二”) string ="I want your" print("out=%s" %string) 注:打印字符串 “I want your” string ="I want your" print("out=%s len%d" %(string ,len("I want your"))) 注: ...

qq_40024178的博客 7302

python输出姓名年龄_Python格式化输出--%s,%d,%f的代码解析

String(字符型)–%s integer(整形)–%d float(浮点型)–%f实例我们需要输出一个人的信息代码:#coding=utf-8#输出一个人的基本信息:姓名:%s 爱好:%s 年龄:%d 岁 身高:%d cm 体重:%f kgstring = "输出一个人的基本信息:姓名:%s 爱好:%s 年龄:%d 岁 身高:%d cm 体重:%f kg"name1 = "周杰伦"hobby1...

weixin_39942637的博客 5022

Python常用字符串格式化方法及格式化操作符辅助说明%c,%s,%d,%o,%x,%e,%f,%g,-,+,#,0

一、常用字符串格式化方法 1.%c,格式化字符及其ASCII码(a = 97) ‘%c %c %c’% (97,98,99) ‘a b c’ 2.%s,格式化字符串 ‘%s’ % ‘hello world’ ‘hello world’ 3.%d,格式化整数 ‘%d + %d = %d’ % (4,5,4+5) ‘4 + 5 = 9’ 4.%o,格式化无符号八进制数(十进制的24相当于八进制的30) ‘%o’ % 24 ‘30’ 5.%x,格式化无符号十六进制数(十进制的10相当于十六进制的a,十进制的16

qq_40662487的博客 4万+

Python中格式化输出%s和%d的区别

python print格式化输出。 1. 打印字符串 print ("His name is %s"%("Aviad")) 效果: 2.打印整数 print ("He is %d years old"%(25)) 效果: 3.打印浮点数 print ("His height is %f m"%(1.83)) 效果: 4.打印浮点数(指定保留小数点位数) print ...

dxt16888的博客 7237

python中格式符的应用%s,%d,%f以及format()的实例以及输出格式

python中格式符的应用%s,%d,%f以及format()的实例以及输出格式   python中格式符的应用%s,%d,%f以及format()的实例以及输出格式 2017年12月25日 17:44:14 阅读数:792 标签: python 更多 个人分类: python 版权声明:提倡知识共享,可以转载和使用 https://blog.csdn.net/Mr_Cat123/art...

caizongxu的博客 5155

Python里的%s和%d是什么意思

二元运算符 % 1)%是一个二元运算符,在实数运算中用来实现取莫的操作,比如: In [53]: 5 % 2 Out[53]: 1 2) 除此之外%与格式字符叠加使用,可以实现参数格式化的功能,比如: In [55]: template = '%s is a lovely girl who is %.0f years old, living in %s Pro ..

fwj_ntu的博客 1万+
上一篇: python常用库 - NumPy 和 sklearn入门
下一篇: 基于python的七种经典排序算法,你知道几种?
测试小小小
博客等级 码龄6年 265粉丝 364原创
评论 1
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值
⌂ 换网址