# 示例代码:将字符串转换为大写
# 定义一个字符串
original_string = "hello world"
# 使用 upper() 方法将字符串转换为大写
upper_string = original_string.upper()
# 输出结果
print(upper_string) # 输出: HELLO WORLD
upper() 是 Python 字符串的一个内置方法,用于将字符串中的所有小写字母转换为大写字母。original_string 是一个包含小写字母的字符串,通过调用 upper() 方法后,生成了一个新的字符串 upper_string,其中所有的字母都被转换为大写。上一篇:python web服务器
下一篇:python os.remove
Laravel PHP 深圳智简公司。版权所有©2023-2043 LaravelPHP 粤ICP备2021048745号-3
Laravel 中文站