In [1]: #欢迎来到“只读课堂”!
In [2]: #今天我来补充一下字符串的变量知识。
...: line = 'ASDFASDFEWFSDF'
In [3]: line.count('A')
Out[3]: 2
In [4]: #它用来数我们变量中所含有的字符的数量
In [5]: line.count('Z')
Out[5]: 0
In [6]: #这样的时候就没有了
In [7]: #——————————————————————————————————————————————————————————————————————
In [8]: #下面的语句用来检测变量以什么结尾
In [9]: line.endwith('SDF')
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-9-754553142250> in <module>()
----> 1 line.endwith('SDF')
AttributeError: 'str' object has no attribute 'endwith'
In [10]: line.endswith("SDF")
Out[10]: True
In [11]: #如果是的话就会输