Python 字符串转大写:使用 upper() 方法
可以使用字符串的 'upper()' 方法将字母转换为大写字母。
例如:
text = 'hello world'
uppercase_text = text.upper()
print(uppercase_text) # 输出: 'HELLO WORLD'
在上面的例子中,我们首先定义了一个字符串 'text',然后使用 'upper()' 方法将其转换为大写字母,并将结果存储在变量 'uppercase_text' 中。最后,我们通过 'print()' 函数将结果输出到控制台。
原文地址: https://www.cveoy.top/t/topic/lGMu 著作权归作者所有。请勿转载和采集!