Lists|Lists and Membership Operaters
Data Type
【Lists|Lists and Membership Operaters】Lists can contain any mix and match of the data types you have seen so far.
list_of_random_things= [1,3.4,'a string',True]#integer,float,string,booleanprint(list_of_random_things[0])# attention it is 'True' not 'Ture'
Print Lists The location of data
list_of_random_things= [1,3.4,'a string',True]print(list_of_random_things[len(list_of_random_things)])# IndexError: list index out of range
list_of_random_things= [1,3.4,'a string',True]print(list_of_random_things[len(list_of_random_things)-1])# output:True
Print from last one
>>>list_of_random_things[-1]True>>>list_of_random_things[-2]a string
Print from x->y
>>>list_of_random_things= [1,3.4,'a string',True]>>>list_of_random_things[1:2]#or[(from the first one to the second if the ''is behind 2 it is the second to the last one):2][3.4]
Judge in or not in
>>>'this'in'this is a string'True>>>'in'in'this is a string'True>>>'isa'in'this is a string'False>>>5notin[1,2,3,4,6]True>>>5in[1,2,3,4,6]False
推荐阅读
- android第三方框架(五)ButterKnife
- Android中的AES加密-下
- Eddy小文
- 带有Hilt的Android上的依赖注入
- android|android studio中ndk的使用
- Android事件传递源码分析
- RxJava|RxJava 在Android项目中的使用(一)
- Android7.0|Android7.0 第三方应用无法访问私有库
- 深入理解|深入理解 Android 9.0 Crash 机制(二)
- EditText默认不获取焦点弹出键盘