ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
#### 示例 ~~~ str = 'hello python' list = [1, 2, "hello", 'python'] ~~~ #### 索引 ``` 正索引 print(str[1]) print(list[3]) 负索引 print(str[-1]) print(list[-2]) ``` #### 切片 ``` str[1:2] str[:2] str[1:] str[:] 步长 str[1:2:2] # 步长为2 str[::2] ``` #### 相加 ``` str1 = 'abc' str2 = 'def' str = str1 + st2 list1 = [1,2,3] list2 = [4,5,6] list = list1 + list2 ``` #### 相乘 ``` str * 5 list * 3 ``` #### 成员资格 ``` in 'n' in str 'hello' in list ``` ``` not in 'n' not in str 'hello' not in list ``` #### 内置函数 ``` len(str) max(list) min(list) ```