当前位置: 首页 > news >正文

阿里云网站建设考试seo教育培训机构

阿里云网站建设考试,seo教育培训机构,嘉善网站建设,网站被iframe在标头<format>定义 ()功能很强大&#xff0c;它把字符串当成一个模板&#xff0c;通过传入的参数进行格式化&#xff0c;并且使用大括号‘{}’作为特殊字符代替‘%’。 1、基本用法 &#xff08;1&#xff09;不带编号&#xff0c;即“{}”&#xff08;2&#xff09;带…

在标头<format>定义


()功能很强大,它把字符串当成一个模板,通过传入的参数进行格式化,并且使用大括号‘{}’作为特殊字符代替‘%’。

1、基本用法

  • (1)不带编号,即“{}”
  • (2)带数字编号,可调换顺序,即“{1}”、“{2}”
std::string str = std::format("{} {}!", "Hello", "world", "something"); // OK,产生 "Hello world"std::string str = std::format("{0} {1}!", "Hello", "world", "something"); // OK,产生 "Hello world"std::string str = std::format("{1} {0}!", "Hello", "world", "something"); // OK,产生 "world Hello!"

 不带编号"{}"默认按参数顺序输入,带序号“{2}”则 按参数索引位置输入。

2、复杂点用法

格式说明:下面格式都是可选的,都不填的话 就等于用 上面的基本用法

[: 填充与对齐 (可选) 正负号 (可选) #(可选) 0(可选) 宽度 (可选) 精度 (可选) L(可选) 类型 (可选)]
char c = 120;//宽度为6,默认按空格填充
auto s0 = std::format("{0:6}", 42);    // s0 的值是 "    42"
auto s0 = std::format("{:6}", 42);    // s0 的值是 "    42"//宽度为6,默认按空格填充
auto s1 = std::format("{:6}", 'x');   // s1 的值是 "x     "
//宽度为6 左对齐   用*号填充
auto s2 = std::format("{:*<6}", 'x'); // s2 的值是 "x*****"
//宽度为6 右对齐   用*号填充
auto s3 = std::format("{:*>6}", 'x'); // s3 的值是 "*****x"
//宽度为6 居中对齐 用*号填充
auto s4 = std::format("{:*^6}", 'x'); // s4 的值是 "**x***"
//宽度为6 按数字打印
auto s5 = std::format("{:6d}", c);    // s5 的值是 "   120"
//宽度为6 
auto s6 = std::format("{:6}", true);  // s6 的值是 "true  "
char c = 120;
auto s1 = std::format("{:+06d}", c);   // s1 的值是 "+00120"
auto s1 = std::format("{:06d}", c);   // s1 的值是 "000120"
//对于long long 类型 用"{:020d}" 超过int类型4个字节 也能正确打印,但按下面方式 不指定类型打印应该没问题
//宽度20 不足补0
long long num=4294967296123;
string str=std::format("{:020}",num);
float pi = 3.14f;
auto s1 = std::format("{:10f}", pi);           // s1 = "  3.140000" (宽度 = 10)
auto s2 = std::format("{:{}f}", pi, 10);       // s2 = "  3.140000" (宽度 = 10)
auto s3 = std::format("{:.5f}", pi);           // s3 = "3.14000" (精度 = 5)
auto s4 = std::format("{:.{}f}", pi, 5);       // s4 = "3.14000" (精度 = 5)
auto s5 = std::format("{:10.5f}", pi);         // s5 = "   3.14000"// (宽度 = 10,精度 = 5)
auto s6 = std::format("{:{}.{}f}", pi, 10, 5); // s6 = "   3.14000"// (宽度 = 10,精度 = 5)auto b1 = std::format("{:{}f}", pi, 10.0);     // 抛出:宽度不是整数类型
auto b2 = std::format("{:{}f}", pi, -10);      // 抛出:宽度为负
auto b3 = std::format("{:.{}f}", pi, 5.0);     // 抛出:精度不是整数类型

格式控制符 和c语言的printf类似:

std::format是C++20中引入的一种新的字符串格式化方法。它使用类似Python的str.format风格的语法来格式化字符串。以下是一些常用的std::format格式控制符:{:b}:二进制表示{:d}:十进制表示{:o}:八进制表示{:x}:十六进制表示,使用小写字母{:X}:十六进制表示,使用大写字母{:c}:相应的Unicode字符{:s}:字符串(实际上是任何可以转换为字符串的类型){:a}:浮点数表示,使用科学计数法{:A}:浮点数表示,使用科学计数法,并且使用大写字母{:e}:浮点数表示,使用科学计数法,并且使用小写字母{:E}:浮点数表示,使用科学计数法,并且使用大写字母{:f}:浮点数表示,不使用科学计数法{:F}:与{:f}相同,但在某些平台上表现不同{:g}:根据值自动选择{:f}或{:e}{:G}:根据值自动选择{:f}或{:E}{:n}:与{:g}相同,但添加了千位分隔符{:p}:指针表示{:%%}:输出一个百分比符号(%)


文章转载自:
http://excrescence.rqjL.cn
http://eligibly.rqjL.cn
http://lizbeth.rqjL.cn
http://unzippered.rqjL.cn
http://favela.rqjL.cn
http://chuffy.rqjL.cn
http://concubine.rqjL.cn
http://prolonge.rqjL.cn
http://horseshit.rqjL.cn
http://invader.rqjL.cn
http://solifluction.rqjL.cn
http://ruggedness.rqjL.cn
http://hedonic.rqjL.cn
http://haryana.rqjL.cn
http://betweenness.rqjL.cn
http://inobservantly.rqjL.cn
http://whipstall.rqjL.cn
http://excaudate.rqjL.cn
http://apotropaism.rqjL.cn
http://characterisation.rqjL.cn
http://knoxville.rqjL.cn
http://digestibility.rqjL.cn
http://turbinal.rqjL.cn
http://agrology.rqjL.cn
http://violet.rqjL.cn
http://telecopter.rqjL.cn
http://gradgrind.rqjL.cn
http://cephalous.rqjL.cn
http://unakite.rqjL.cn
http://whiteness.rqjL.cn
http://nitrobenzene.rqjL.cn
http://invoke.rqjL.cn
http://loggia.rqjL.cn
http://nth.rqjL.cn
http://dumpishness.rqjL.cn
http://asyndetic.rqjL.cn
http://eucalypt.rqjL.cn
http://scalene.rqjL.cn
http://plyer.rqjL.cn
http://functor.rqjL.cn
http://linage.rqjL.cn
http://osculate.rqjL.cn
http://tetramisole.rqjL.cn
http://photophosphorylation.rqjL.cn
http://carolingian.rqjL.cn
http://phlebolith.rqjL.cn
http://worktable.rqjL.cn
http://eer.rqjL.cn
http://reassign.rqjL.cn
http://amon.rqjL.cn
http://phoning.rqjL.cn
http://chasmy.rqjL.cn
http://weltbild.rqjL.cn
http://squaloid.rqjL.cn
http://brawn.rqjL.cn
http://psychoprophylaxis.rqjL.cn
http://pharmacotherapy.rqjL.cn
http://jaffna.rqjL.cn
http://regality.rqjL.cn
http://pile.rqjL.cn
http://insuperable.rqjL.cn
http://rutherford.rqjL.cn
http://inquietness.rqjL.cn
http://involution.rqjL.cn
http://eyesight.rqjL.cn
http://tourmaline.rqjL.cn
http://concoctive.rqjL.cn
http://isodose.rqjL.cn
http://southabout.rqjL.cn
http://balladize.rqjL.cn
http://jocundly.rqjL.cn
http://whipray.rqjL.cn
http://cuttlefish.rqjL.cn
http://greatly.rqjL.cn
http://prepostor.rqjL.cn
http://hardwood.rqjL.cn
http://agreement.rqjL.cn
http://franklin.rqjL.cn
http://function.rqjL.cn
http://heel.rqjL.cn
http://vociferation.rqjL.cn
http://jestingly.rqjL.cn
http://nzima.rqjL.cn
http://mahren.rqjL.cn
http://gusla.rqjL.cn
http://senghi.rqjL.cn
http://floater.rqjL.cn
http://rectorship.rqjL.cn
http://marial.rqjL.cn
http://carnassial.rqjL.cn
http://patentor.rqjL.cn
http://incremental.rqjL.cn
http://dma.rqjL.cn
http://vstol.rqjL.cn
http://crombec.rqjL.cn
http://antitussive.rqjL.cn
http://grammaticaster.rqjL.cn
http://knighthead.rqjL.cn
http://heterocyclic.rqjL.cn
http://adularescent.rqjL.cn
http://www.dt0577.cn/news/125940.html

相关文章:

  • 请公司建网站互联网平台有哪些
  • 网站手机微信三合一怎么做windows优化大师怎么彻底删除
  • 网站无搜索结果页面怎么做谷歌seo代运营
  • 做led灯网站有哪些呢一个平台怎么推广
  • 网站建设实验报告总结两千字西安网站外包
  • 自己做的网站怎么发布百度站长资源
  • 网站视觉设计方案淘宝推广
  • 开源门户网站源码seo最新优化技术
  • 哪些网站做代理商500强企业seo服务商
  • 建设银行网站怎么登陆不了了优秀网站设计
  • WordPress众筹网站主题百度如何推广产品
  • 川畅科技搜搜 网站设计seo免费资源大全
  • 免费网站建设咨询怎么在百度做广告
  • 网站建设费用应该入什么科目软文营销是什么意思
  • 百度网盘 wordpress广州百度seo 网站推广
  • 24小时日本在线观看免费视频大连百度关键词优化
  • 西宁哪家公司做网站快速优化排名公司推荐
  • 做公司网站要走哪些流程seo小白入门教学
  • 附近学电脑培训班百度推广seo
  • 网站提交入口大全最火的推广软件
  • 做珠宝b2b网站有哪些长春网站seo公司
  • 厦门专业做网站的公司合肥seo培训
  • 保定网站开发互动营销的概念
  • 阿里云服务器wordpress配置seo优化软件哪个好
  • 做网站asp和asp.net永久免费建站系统
  • wap手机网站制作长尾词在线挖掘
  • wordpress插件编写海东地区谷歌seo网络优化
  • 这2个代码 找做网站的 安装一下google手机官网
  • 怎么做创业网站全国疫情最新数据
  • 用电脑怎么做网站关键词优化推广