删除空白
比较两个字符串是否相同,空白有很大作用
python能够找出字符串首尾的空白
>>> sentence = ‘python ’
>>> sentence.rstrip()
'python'
>>> sentence = sentence.rstrip()
>>> sentence
'python'
字符串语法错误
- ’ 字符串 ’ 中不能包含 ‘ ,解决:用双引号“ ‘ ”
- 类型错误:
>>> age = 23
>>> message = " happy " + age + " birthday "
!!!!! wrong python 无法解读 int 变量,作为数值还是字符
>>> message = " happy " + str (age) + " birthday "