|
|
发表于 2026-6-23 11:37:14
|
显示全部楼层
请注意不要直接复制粘贴程序到IDLE的交互模式中,会报错,例如:
- Python 3.8.5 (tags/v3.8.5:580fbb0, Jul 20 2020, 15:57:54) [MSC v.1924 64 bit (AMD64)] on win32
- Type "help", "copyright", "credits" or "license()" for more information.
- >>> for year in range(2018,2100):
- if (year % 4 == 0) and (year % 100 != 0) or (year % 400 == 0):
- break
- print('2018年后出现的第一个闰年',year)
- SyntaxError: invalid syntax
- >>>
复制代码
请点击file---newfile,粘贴后保存,再按F5运行。
关于IDLE如何使用以及详细的操作步骤,请看小甲鱼教程:https://www.bilibili.com/video/BV1c4411e77t?t=80.2&p=3 |
|