Discuss / Python / 运行为啥没错误抛出?

运行为啥没错误抛出?

Topic source
  1 def foo(s):
  2     n = int(s)
  3     assert n != 0, 'n is zero!'
  4     return 10 / n
  5 def main():
  6     foo('0')

/usr/bin/python3.4 /home/nemo_chen/python/err.py

Process finished with exit code 0

你自己根本就没有调用main()这个函数,所以肯定不会出错了,后面你直接加一句调用main()的语句就好


  • 1

Reply