Python笔记——字符串

Python简单的字符串

Python 3.7.3 (v3.7.3:ef4ec6ed12, Mar 25 2019, 22:22:05) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license()" for more information.
>>> 'I am learning Python.'
'I am learning Python.'
>>> x='I am learning Python.'
>>> x
'I am learning Python.'
>>> type(x)

>>> "I am learning Pythone."
'I am learning Pythone.'
>>> 'I \'m learning Python.'
"I 'm learning Python."
>>> 

Python实现HelloWord

Python 3.7.3 (v3.7.3:ef4ec6ed12, Mar 25 2019, 22:22:05) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license()" for more information.
>>> Fist_word = 'Hello'
>>> Secend_word = 'World!'
>>> print(Fist_word+Secend_word)
HelloWorld!
>>> print(Fist_word+" "+Secend_word)
Hello World!
>>> 

Python字符串方法

1.获取字符串长度

>>> Mom_said = "Tom is good boy"
>>> len(Mom_said)
15
>>> 

2.判断是否都是小写

>>> Mom_said = "Tom is good boy"
>>> Mom_said.islower()
False
>>> 

3.获取某个字符在字符串里面的数量

>>> Mom_said = "Tom is good boy"
>>> Mom_said.count('o')
4
>>> 

你可能感兴趣的:(Python笔记——字符串)