python - 如何在 Python 中使用 .upper 函数格式化大写的完整句子?
问题描述
我想从我的代码中生成一行,以便它以大写形式显示。
这是我到目前为止的代码:
a= 98
b= 88
c= 78
d = """ I want {} kilos of gram
and it want {} kilos of magi also i want
{} of ginger """
print(d.format(a,b,c) and (d.upper()))
输出应显示为:
"""我想要 {98} 公斤的克,它想要 {88} 公斤的魔法师,我还想要 {78} 的生姜 """
解决方案
a= 98
b= 88
c= 78
d = """ I want {} kilos of gram
and it want {} kilos of magi also i want
{} of ginger """
print(d.format(a,b,c).upper()) # modification is here
Out[1]:
I WANT 98 KILOS OF GRAM
AND IT WANT 88 KILOS OF MAGI ALSO I WANT
78 OF GINGER
推荐阅读
- r - 如何在我的绘图上排列按 Y 排序的 X 轴?
- javascript - 使用 swagger-jsdoc 记录 express API 的具体步骤是什么?
- perforce - 更新客户端的列表以反映 HD 中的内容
- db2 - 在 db2 表中加载挂起状态
- firebase - Firestore 规则允许读取条件时间戳问题
- swift - 如何在 Swift 中使用“扩展字符串分隔符”?
- c# - 获取图表轴的最后一个刻度
- python - 字典字典的字符串
- android - Android - 位置粘性(CSS)在android webview中不起作用
- gulp - 找不到模块'babel-preset-env'