标签:字符串 基础 key 对象 循环 用户 python基础 ring for
for循环:用户按照顺序循环可迭代对象的内容
msg = "string"
for i in msg:
print(i)
执行结果为:
s
t
r
i
n
g
lst = ["a", "b", "c"]
for i in lst:
print(i)
执行结果为:
a
b
c
dic = {
"name": "yang",
"age": 18,
"sex": "male"
}
for key, value in dic.items():
print(key, value)
执行结果为:
name yang
age 18
sex male
标签:字符串 基础 key 对象 循环 用户 python基础 ring for
原文地址:https://www.cnblogs.com/yang-wei/p/9630508.html