在Python中创建“ two_days_in_a_row”是什么数据类型?是否创建列表或元组,或其他任何数据类型
在Coursera课程1,第4周,发行课程的我的Python高级数据科学教授中,教授说two_days_in_a_row = 0将创建一个列表。我仍然在想为什么会这样,为什么会创建一个列表。帮我知道答案。提前致谢!!!
two_days_in_a_row = 0
#creates a list
答案 0 :(得分:0)
您已为该变量分配了整数值。
使用type()
会告诉您所拥有的数据类型。
IE:type(two_days_in_a_row)
->返回int
答案 1 :(得分:0)
请勿混淆,请在python中检查以下数据类型
two_days_in_a_row = 0
type(two_days_in_a_row): int
two_days_in_a_row = []
type(two_days_in_a_row): list
two_days_in_a_row = None
type(two_days_in_a_row): NoneType
two_days_in_a_row = ""
type(two_days_in_a_row): str
two_days_in_a_row = {}
type(two_days_in_a_row): dict
two_days_in_a_row = ()
type(two_days_in_a_row): tuple
two_days_in_a_row = 0.0
type(two_days_in_a_row): float
two_days_in_a_row = 2+3j
type(two_days_in_a_row): complex
two_days_in_a_row = True
type(two_days_in_a_row): bool