字符串的连接
直接使用“+”连接字符串
代码
# -*- coding: UTF-8 -*-
import os,sys
say='hello!'
say=say+'Morning!'
print('len',len(say))
print(say[0])
print(say[5])
print(say[0:5])
print(say[:5])
print(say[5:13])
print(say[0:-7])
print(say[:-7])
以下再列举两种有趣的连接方法:
直接使用“+”连接字符串
# -*- coding: UTF-8 -*-
import os,sys
say='hello!'
say=say+'Morning!'
print('len',len(say))
print(say[0])
print(say[5])
print(say[0:5])
print(say[:5])
print(say[5:13])
print(say[0:-7])
print(say[:-7])