python之str基础类型

1、索引以及切片

s = 'python24期'
#下标(索引)
s1 = s[0]
print(s1,type(s1))
s2 = s[2]
print(s2)
s3 = s[8]
print(s3)
s33 = s[-1]
print(s33)

结果:

猜你喜欢

转载自www.cnblogs.com/wangkaiok/p/9840169.html