作者eco100 ( )
看板Python
标题[问题] if判断式里面可以指定跳到某一行执行吗
时间Wed Dec 15 15:16:03 2021
python 新手想问个判断式的问题
就是我想写出下列的效果
if number < 100:
print("test")
else:
跳至某一行开始执行
我的问题就是 跳至某行重新执行那里
python 可以有什麽样的写法吗?
谢谢!
--
※ 发信站: 批踢踢实业坊(ptt.cc), 来自: 140.109.32.9 (台湾)
※ 文章网址: https://webptt.com/cn.aspx?n=bbs/Python/M.1639552565.A.3BD.html
1F:→ juijuijuijui: python 没有go to要另外安装,但不建意使用 12/15 15:20
2F:→ OrzOGC: 写个func call它 12/15 15:32
3F:→ oToToT: go to statement considered harmful 12/15 16:35
4F:推 yiche: 二楼正解 12/15 17:36
5F:推 kukuwu: 教授没叫你别用goto吗 12/15 18:15
6F:推 s0914714: 可能是C要改成Python吧 12/15 18:16
7F:推 Schottky: longjmp() 不算的话,C 也很少人在用 goto 的 12/15 19:50
8F:→ DavisX: fortran常用goto xdd 12/15 21:20
9F:推 fdvd: 同二楼 12/16 11:24
10F:→ mantour: 我看过用最多goto的也是Fortran的程式,一个明明很简单 12/16 19:36
11F:→ mantour: 的叠代回圈看了三遍才懂 12/16 19:36
12F:推 TitanEric: c的goto如果确定逻辑清楚很好用 linux kernel很常见 12/16 19:55
13F:→ TitanEric: 但python没得选择 只能设flag 12/16 19:55
14F:推 s0914714: C的goto用在error handling反而具有可读性 12/16 20:02
15F:→ s0914714: 不过也不知道原PO的需求是啥 毕竟这个要求真的很奇怪 12/16 20:03