课程 \
Python3 入门教程
3-9 Python的字符串切片
# Enter a code
a='AABCDEFGHHIJ'
print(a[1:9])
print('AABCDEFGHHIJ'[1:9])
2022-02-02
查看完整代码
3-7 Python的字符串format
# Enter a code
tem='Life is short{}you need Python{}'
res=tem.format(',','.')
print(res)
template = 'Hello {}, Hello {}'
result = template.format('World', 'China')
print(result)
template='Life is short,{}you need Python.{}'
res=template.format('','')
print(res)
print('Life is short, you need {}'.format('Python'))
2022-02-02
查看完整代码
3-6 Python中raw字符串与多行字符串
# Enter a code
print(r'''Python is created by "Guido".
It is free and easy to learn.
Let's start learn Python in imooc!''')
print(r'''"To be,or not to be":that is the question.
Whether it's nobler in the mind to suffer.''')
print('''Line 1
Line 2
Line 3''')
print('''Line 1
Line 2Line 3''')
2022-02-02
查看完整代码
3-5 Python的字符串
# Enter a code
print('Bob said \"I\'m OK\".')
print('special string:\',\",\\,\\\,\\n,\\t')
2022-02-02
查看完整代码
3-4 Python的布尔类型
# Enter a code
a='python'
print('hello,',a or 'world')
b=''
print('hello,',b and 'world')
b=''
print('hello,',b and 0)
2022-02-02
查看完整代码
首页上一页123下一页尾页