Python快速入门 - for循环

for循环 - 遍历字符串

str = "HP"
for c in str:
  print(c)

测试

H
P

for else

for c in str:
  print(c)
else:
  print('end')

测试

H
P
end

你可能感兴趣的:(Python快速入门 - for循环)