python 数据类型

2020-01-16  本文已影响0人  大雨滂沱在关外

value = 1
print(value) # 数字
print(type(value))

value = 'v'
print(value) # 字符
print(type(value))

value = "hello world"
print(value) # 字符串
print(type(value))

print("===============元祖================")
value = (1,2)
print(value) # 元祖 tuple
print(value[0])
print(value[1])
print(type(value))
for val in value:
print(val)

print("===============列表================")
value = [1,2]
print(value) # 列表 list
print(value[0])
print(value[1])
print(type(value))
for val in value:
print(val)

print("===============字典================")
value = {1,2}
print(value) # 字典 dict
value = {"name":"hahah","age":12}
print(value) # 字典是不能使用索引位置访问的。
print(value)
print(type(value))
for val in value: # for 打印出来key 没有value
print(val)

image.png
上一篇 下一篇

猜你喜欢

热点阅读