python - 在 Python 中除以零会导致 Windows 98 等崩溃吗?

标签 python windows

一位教授告诉我,如果在 Windows 98 中除以零或取负平方根,Python 会崩溃。

这似乎很荒谬,因为 Python 是一种解释型语言,但我没有办法验证这一点,而且 Windows 是臭名昭著的……任何人都可以证实或否认这种说法吗?如果是这样,是否与 Python 是用 C 语言编写的事实有关? (C 真的会因为被零除而使整个操作系统崩溃吗!?)

最佳答案

它应该会导致 ZeroDivisionError 异常。我无法想象为什么这在 Windows 98 中会有所不同。

>>> 1/0
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ZeroDivisionError: integer division or modulo by zero

多么浪费时间。

Win98 下 Python 2.3.5

Python 2.3.5 (#62, Feb  8 2005, 16:23:02) [MSC v.1200 32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more information.

    ****************************************************************
    Personal firewall software may warn about the connection IDLE
    makes to its subprocess using this computer's internal loopback
    interface.  This connection is not visible on any external
    interface and no data is sent to or received from the Internet.
    ****************************************************************

IDLE 1.0.5      
>>> import sys
>>> sys.getwindowsversion()
(4, 10, 67766446, 1, ' A ')
>>> sys.version_info
(2, 3, 5, 'final', 0)
>>> 1/0

Traceback (most recent call last):
  File "<pyshell#3>", line 1, in -toplevel-
    1/0
ZeroDivisionError: integer division or modulo by zero
>>>

关于python - 在 Python 中除以零会导致 Windows 98 等崩溃吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9369899/

相关文章:

c# - 检查斜杠的字符串

c# - 如何在不更改主机文件的情况下阻止对特定站点的访问,直到重新启动?

java - 批处理文件执行可以单步执行序列而不完成 java 进程吗?

python - 使用 einsum 对 numpy 进行进一步优化以进行堆叠矩阵向量乘法

python - Python 中的 4 个子图条形图

python - gunicorn 服务器启动时出错

c++ - Windows 程序中的 WM_QUIT、WM_CLOSE 和 WM_DESTROY 有什么区别?

python - 位置参数和关键字参数的求值顺序

python - 如何修复 'TypeError: unhashable type: ' 列表错误?

windows - 通过 curl 命令行发送到 github (Windows)