Python: 字符串全部小写或大写-upper()与lower()函数

一、upper函数

  • 语法:str.upper()
  • 返回值:返回一个新的字符串,其中所有字符都被转换为大写。
python`s = "hello world"  
print(s.upper())  # 输出:HELLO WORLD`

二、lower函数

  • 语法:str.lower()
  • 返回值:返回一个新的字符串,其中所有字符都被转换为小写。
python`s = "HELLO WORLD"  
print(s.lower())  # 输出:hello world`

猜你喜欢

转载自blog.csdn.net/Ethan_Rich/article/details/135021188