python 3 days

python 3 days

1,基础数据类型初识

int:用于计算

str:“abcs”,“1244535”,存储少量的数据

bool:True ,Flase

list:[ "name","True",[ ]......],各种数据类型的数据,大量的数据,便于操作

tuple:元组()只读列表

dict:{"name":"老男孩",

         "name_list":["反面教材"],....},存储大量的数据,关系型数据。

set:{"juxiansheng,"kangsir",....}

    int:用于计算。
str:'alex' ,'1235443543',存储少量的数据。
'[1,2,3]'
bool:True, False.
list: ['name',True,[]....],各种数据类型的数据,大量的数据,便于操作.
tuple 元组。() 只读列表。
dict:{'name':'老男孩',
'name_list':['反面教材',.....]
'alex':{'age':40,
'hobby':'old_women',
}
},
存储大量的数据,关系型数据。
set:{'wusir', 'alex', ....}
2,int
3,bool
int<--->str
str--->int int(str)条件:字符串必须全部由数字组成。
int --->str str(int)
age = int(input('>>>'))
print(age,type(age))
s1 = str(123)
s2 = 123
print(s1,type(s1))
print(s2,type(s2))
bool<---> int True --->1 False ---> 0
int ----> bool 非零即为True,零 False
print(int(True)),print(int(False))
print(bool(100)),print(bool(-1)),print(bool(0))
bool ---> str str(True) str(False)
str ---> bool 非空即为 True  ''空字符串 --> False
4,str
索引,切片,步长
索引:
s1 = s[0]
print(s1,type(s1))
s2 = s[4]
print(s2)
s3 = s[2]
prit(s3)
切片:
s6 = s[0:6] # 切片 :顾头不顾腚
s6 = s[:6] # 切片 :顾头不顾腚
# s = 'python12期'
# print(s6)
# s7 = s[1:4]
# print(s7)
# s8 = s[1:]
# print(s8)
# s9 = s[:]
# print(s9)
原文地址:https://www.cnblogs.com/juxiansheng/p/8968309.html