数据类型:不同的变量值需要不同类型的数据来表示
age = 10
print(type(age))
<class 'int'>
x = int('1111')
print(type(x))
<class 'int'>
长整型只在python2中存在,python3中不存在长整型。
x = 11111111111111111111111111111111111111111111111
print(type(x)) # longint
id不变值可变,即在原值的基础上修改,则为可变数据类型;值变id也变,即重新申请一个空间放入新值,则为不可变数据类型。
age = 19
print(f'first:{id(age)}')
age = 20
print(f'second:{id(age)}')
first:4384901776
second:4384901808
age = 5.5
print(type(age))
<class 'float'>
age = ('111111')
print(age)
print(type(age))
111111
<class 'str'>
y = float('11.1')
print(y)
print(type(y))
11.1
<class 'float'>
有序:可以按照索引把元素提取出来
无序:无索引
weight = 83.4
print(f'first:{id(weight)}')
high = 176.5
print(f'second:{id(high)}')
first:6479152
second:6477408
score = 76.5
print(f"first:{score} {id(score)}")
score+=1
print(f"second:{score} {id(score)}")
原文:https://www.cnblogs.com/zuihoudebieli/p/10914610.html