python中字符串的使用

时间:2019-02-11
本文章向大家介绍python中字符串的使用,主要包括python中字符串的使用使用实例、应用技巧、基本知识点总结和需要注意事项,具有一定的参考价值,需要的朋友可以参考一下。

一、字符串定义方式

a = 'hello'
b = 'what\'s up'
c = "what's up"
print(a)
print(b)
print(c)

二、字符串的特性

1.索引

s = 'hello'
print(s[0])
print(s[1])

2.切片
切片的规则:s[start