#元组
#定义:Python将不能修改的值称为不可变的,而不可变的列表被称为元组。元组看起来犹如列表,但使用圆括号而不是方括号来标识。
teams=(200,60)
print(teams[0])
print(teams[1])
执行结果
200
60
进程已结束,退出代码为 0
teams=(200,60)
#遍历元组中的所有值
for team in teams:
print(team)
执行结果
C:/Users/yong.chen.cd/PycharmProjects/pythonProject1/venv/Scripts/python.exe C:/Users/yong.chen.cd/PycharmProjects/pythonProject1/study_python/tuple_study/tuple2.py
200
60
进程已结束,退出代码为 0
#给元组变量赋值
teams=(200,50)
print(teams)
执行结果
C:/Users/yong.chen.cd/PycharmProjects/pythonProject1/venv/Scripts/python.exe C:/Users/yong.chen.cd/PycharmProjects/pythonProject1/study_python/tuple_study/tuple3.py
(200, 50)
进程已结束,退出代码为 0
原创文章,作者:carmelaweatherly,如若转载,请注明出处:https://blog.ytso.com/tech/pnotes/244280.html