要修改字符串中字符的大小,可以使用字符串的 upper()、lower() 和 capitalize() 方法。
upper() 方法将字符串中的所有字符都转换为大写:string = "hello"new_string = string.upper()print(new_string) # 输出: HELLO使用 lower() 方法将字符串中的所有字符都转换为小写:string = "WORLD"new_string = string.lower()print(new_string) # 输出: world使用 capitalize() 方法将字符串的第一个字符转换为大写,其他字符转换为小写:string = "hello world"new_string = string.capitalize()print(new_string) # 输出: Hello world 

