I was trying out python -mtimeit
so I put python -mtimeit "n = 0; while n < 10: pass"
Then an invalid syntax error showed up. same with semicolon and for loop.
However, when I try semicolon and loop individually. Both worked fine.
python -c "for i in range(10): print(n)"
python -c "n = 1; n = 2; print(n)"
Why is this so and how can I test while loop in timeit? Thank you very much!
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…