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

笨方法学python -练习6

程序:

print("Mary had a little lamb.")

print("Its fleece was white as {}.".format('snow'))

print("And everywhere that Mary went.")

print("." * 10) # what′d that do?

end1 ="C"

end2 ="h"

end3 ="e"

end4 ="e"

end5 ="s"

end6 ="e"

end7 ="B"

end8 ="u"

end9 ="r"

end10 ="g"

end11 ="e"

end12 ="r"

 # watch that comma at the end.  try removing it to see what happens

print(end1 +end2 +end3 +end4 +end5 +end6, end=' ' )

print(end7 +end8 +end9 +end10 +end11 +end12)

运行结果:

Mary had a little lamb.
Its fleece was white as snow.
And everywhere that Mary went.
..........
CheeseBurger

知识点分析:

一 .format 的用法

与{}一起使用,目的解决字符串变量的插入

python之格式化输出format()函数使用总结_python format 打印列表保持对齐-CSDN博客

二、在print()输出语句中出现 end=‘ ’的语句,是什么意思呢?

简单来说,如果没有end=‘ ’,每次print语句都会自动换行,而有了这个语句,数据就不会自动换行,而是在输出的数据后面加上空格(空格数取决于引号里面的空格数)。

引用文章

Python中end=' '的用法_python end用法-CSDN博客

http://www.dtcms.com/a/263181.html

相关文章:

  • MySQL 慢查询日志详解
  • Arduino IDE ESP8266连接0.96寸SSD1306 IIC单色屏显示北京时间
  • 第81题:搜索旋转排序数组Ⅱ
  • PHP:历经岁月沉淀的Web开发利器
  • 如何查看服务器的运行日志?
  • mysql 分组后时间没有按照最新时间倒序
  • PHP安装使用教程
  • 气候智能体:AI如何重构人类应对气候危机的决策体系?
  • FastAPI 学习(二)
  • 三态门Multisim电路仿真——硬件工程师笔记
  • 重构老项目不再“踩雷”:飞算JavaAI的本地化智能合并实战
  • react setstate
  • 【Java面试】10GB,1GB内存,如何排序?
  • 筑牢医疗AI安全防线:四重防护体系全解析
  • kubernetes(k8s)控制器与案例详解
  • 华为云Flexus+DeepSeek征文|​​华为云ModelArts Studio大模型 + WPS:AI智能PPT生成解决方案​
  • xml.etree.ElementTree.ParseError: parsing finished: 错误原因定位
  • 【Docker基础】Docker数据持久化与卷(Volume)介绍
  • 探索 AI 系统提示与模型资源库:`system-prompts-and-models-of-ai-tools`
  • 键盘第一下无反应
  • 敏捷项目开发工具【Focalboard安装指南】
  • 第三十五章 I2S——音频传输接口
  • Reactor操作符的共享与复用
  • 衡石科技使用手册-企业即时通讯工具数据问答机器人用户手册
  • iOS 应用上架踩坑实录:7 个问题 + 工具组合解决方案详解
  • 《从量子奇境到前端优化:解锁卡西米尔效应的隐藏力量》
  • web服务器搭建nginx
  • 力扣1685. 有序数组中差绝对值之和
  • Waiting for another flutter command to release the startup lock...解决方法
  • 【编译原理】期末简答题