words="To be or not to be that is the question"
words1="hey#please#be#kind"
new_words=words.split()
newwords1=words1.split("#")
print("默认空格拆分结果:"+str(new_words))
print("使用指定符号得到拆分结果:"+str(newwords1))
words=" To be or not to be that is the question! "
new_words=words.strip()
print("删除字符串前后空格后:"+str(new_words))
new_words=words.strip(" To")
new_words=words.replace(" be","")
print("删除字符串前后空格后:"+str(new_words))
删除字符串前后空格后:To be or not to be that is the question!
删除字符串前后空格后: To or not to that is the question!
文章目录字符串处理1. split拆分字符串2. strip删除字符串前后的空格3. join连接列表的字符串4. 大小写转换5. 字符与ASCII码的转换6. 英文字母判断7. 组合字符判断字符串处理1. split拆分字符串words="To be or not to be that is the question"words1="hey#please#be#kind"new_wo