惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Apple Machine Learning Research
Apple Machine Learning Research
WordPress大学
WordPress大学
O
OpenAI News
量子位
Last Week in AI
Last Week in AI
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
J
Java Code Geeks
小众软件
小众软件
有赞技术团队
有赞技术团队
V
V2EX
宝玉的分享
宝玉的分享
月光博客
月光博客
腾讯CDC
IT之家
IT之家
博客园 - 【当耐特】
D
Darknet – Hacking Tools, Hacker News & Cyber Security
T
Tenable Blog
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
V
Vulnerabilities – Threatpost
美团技术团队
博客园 - 三生石上(FineUI控件)
博客园_首页
博客园 - Franky
T
Threatpost
阮一峰的网络日志
阮一峰的网络日志
博客园 - 司徒正美
Project Zero
Project Zero
Cyberwarzone
Cyberwarzone
博客园 - 叶小钗
雷峰网
雷峰网
Latest news
Latest news
S
SegmentFault 最新的问题
罗磊的独立博客
Help Net Security
Help Net Security
Hugging Face - Blog
Hugging Face - Blog
Jina AI
Jina AI
P
Proofpoint News Feed
L
LINUX DO - 热门话题
爱范儿
爱范儿
大猫的无限游戏
大猫的无限游戏
酷 壳 – CoolShell
酷 壳 – CoolShell
K
Kaspersky official blog
A
Arctic Wolf
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
G
GRAHAM CLULEY
F
Fortinet All Blogs
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
PCI Perspectives
PCI Perspectives
Security Archives - TechRepublic
Security Archives - TechRepublic

博客园 - xgqfrms

xgqfrms, cnblogs, blogs xgqfrms, cnblogs, blogs xgqfrms, cnblogs, blogs xgqfrms, cnblogs, blogs xgqfrms, cnblogs, blogs xgqfrms, cnblogs, blogs xgqfrms, cnblogs, blogs xgqfrms, cnblogs, blogs xgqfrms, cnblogs, blogs xgqfrms, cnblogs, blogs xgqfrms, cnblogs, blogs xgqfrms, cnblogs, blogs Remotion Video Maker All In One git worktree All In One Tesla 的车机使用什么技术来渲染汽车模型的? 宜家 VEVELSTAD 维维斯托床架 All In One macOS sysmond bug All In One Three.js All In One The COF of LCD Monitor All In One Dell 显示器 S2419HM 灰屏 &花屏 All In One AI Harness Engineering All In One 电脑外接显示器天梯榜 All In One How to change the speed display unit of GSP from mph to km/h using GoPro Labs All In One WHCA 白宫记者协会 All In One Pascal Editor All In One 主流犬种图解指南 All In One 泡沫喷雾 & 辣椒喷雾 All In One 如何给身份证照片添加水印 All In One GoPro MISSION 1 PRO price All In One 杭州历史天气数据 All In One Pandoc All In One GoPro MISSION 1 SERIES All In One GoPro telemetry 中的 GPS5 与 GPS9 是什么 All In One xgqfrms, cnblogs, blogs xgqfrms, cnblogs, blogs xgqfrms, cnblogs, blogs xgqfrms, cnblogs, blogs xgqfrms, cnblogs, blogs OpenCode All In One OpenClaw 设置 cron 定时任务 All In One free MongoDB Cloud API All In One 如何在 Raspberry Pi 安装 OpenClaw All In One free cloud LLM models API All In One Claude Code Free Video Tutorials All In One 如何解决 OpenClaw 升级后导致 feishu plugin 无法使用的问题 All In One Claude Code skills & plugins All In One LLM Benchmark All In One How to fix use the FileZilla FTP upload file error All In One
xgqfrms, cnblogs, blogs
xgqfrms · 2026-04-09 · via 博客园 - xgqfrms

How to run for loop in Python REPL All In One

Python REPL & for loop

error

$ py3
Python 3.10.12 (main, Mar  3 2026, 11:56:32) [GCC 11.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> cart = ["milk", "eggs", "apples"]
>>> for item in cart:
...   print(item)

image

solution

在 Python REPL 中,写完代码块必须按一次回车(空行),告诉解释器“代码结束了”。

在 Python REPL 里写 for 循环要记住:

  1. 冒号 : 必须有
  2. 下面的代码必须缩进
  3. 最后一定要回车空一行才能执行 ✅

https://chatgpt.com/c/69d71360-5844-8329-8e73-ebefdbd37e89

demos

>>> for i in range(3):
...     print(i)
... 
0
1
2
>>> cart = ["milk", "eggs", "apples"]
>>> for item in cart:
...   print(item)
... 
milk
eggs
apples
>>> 

image

refs

https://stackoverflow.com/questions/67310343/using-for-loops-in-python-interpreter



©xgqfrms 2012-2021

www.cnblogs.com/xgqfrms 发布文章使用:只允许注册用户才可以访问!

原创文章,版权所有©️xgqfrms, 禁止转载 🈲️,侵权必究⚠️!