删除空白
Python能够找出字符串开头和末尾多余的空白。要删除空白可用rstrip()(删除末尾空白)、lstrip()(删除开通空白)和strip()(删除两边空白)
favorite_languages = " python "
print("\"" + favorite_languages + "\"")
print("\"" + favorite_languages.rstrip() + "\"")
print("\"" + favorite_languages.lstrip() + "\"")
print("\"" + favorite_languages.strip() + "\"")
字符串大小写切换
title(): 首字母大写
upper(): 全部大写
lower(): 全部小写
name = "Liang chen"
print("小写:" + name.lower())
print("大写:" + name.upper())
print("首字母大写:" + name.title())