以下为本人学习笔记
##去掉空格或者特殊字符
input_str = ' 今天天气不错,挺风和日丽的 '
input_str.strip()#去掉字符串中的空格
input_str.rstrip()#去掉字符串中 最右边的空格
input_str.lstrip()#去掉字符串中 最左边的空格
input_str = 'AAA今天天气不错,挺风和日丽的AAA'
input_str.strip('A')#去掉字符串中的A
input_str.rstrip('A')#去掉字符串中 最右边的A
input_str.lstrip('A')#去掉字符串中 最左边的A
##替换操作
input_str = '今天天气不错,挺风和日丽的'
input_str.replace('今天','昨天')#所有的今天替换成昨天
input_str.replace('今天','')#去掉所有的今天
##查找操作
input_str.find('今天')
##判断操作
input_str.isalpha()#判断是否全是字母
input_str = 'ABC'
input_str.isalpha()#判断是否全是字母
input_str.isdigit()#是否全是数字
##分割和合并操作
input_str= '今天 天气 不错,挺 风和日丽 的'
input_str.split(' ')#按空格分割(只打印)
input_str = input_str.split(' ')#按空格分割(修改)
' '.join(input_str)#以空格分隔符把所有的词串起来
####帮助文档
help(str)