Warning: Undefined array key "fancybox" in /home/techback/techback.info/public_html/wp-content/plugins/responsive-lightbox/includes/class-frontend.php on line 85
Warning: Undefined array key "fancybox" in /home/techback/techback.info/public_html/wp-content/plugins/responsive-lightbox/includes/class-frontend.php on line 88
Warning: Trying to access array offset on value of type null in /home/techback/techback.info/public_html/wp-content/plugins/responsive-lightbox/includes/class-frontend.php on line 88
普通のFor文
items = [
{ id: 1, "name": "a"},
{ id: 2, "name": "b"},
]
for item in items:
print(str(item[id]) + item["name"])
# 1a
# 2b
for文でIndex値も取得する(Indexの開始値を指定)
items = [
{ id:1,"name":"a"},
{ id:2,"name":"b"},
]
for i,item in enumerate(items,2):
print(str(i) + ':' + str(item[id]) + item["name"])
# 2:1a
# 3:2b
雑感
PythonのFor文でよく使用するものを記載。