python修改的常用方法

python修改的常用方法:

# mystr = "hello world and itcast and itheima and Python"

# 1. capitalize() 字符串首字母大写
# new_str = mystr.capitalize()

# 2.title(): 字符串中每个单词首字母大写
# new_str = mystr.title()

# 3. upper():小写转大写
# new_str = mystr.upper()

# 4. lower(): 大写转小写
# new_str = mystr.lower()
# print(new_str)

mystr = "   hello world and itcast and itheima and Python   "
print(mystr)
# 1. lstrip(): 删除左侧空白字符
# new_str = mystr.lstrip()

# 2. rstrip(): 删除右侧空白字符
# new_str = mystr.rstrip()

# 3.strip():删除两侧空白字符
new_str = mystr.strip()
print(new_str)

你可能感兴趣的:(opencv,tensorflow,python,开发语言,后端)