【问题标题】:Does Isinstance Exist in Python Version 3.7? [closed]Python 3.7 版中是否存在 Isinstance? [关闭]
【发布时间】:2020-06-03 15:39:38
【问题描述】:

我正在使用 Visual Studio 2019 来学习用 3.6.1 编写的 Python 培训课程,并且正在使用 Python 3.7 版本编写;但是,当我编写 isinstance 时,它​​的颜色并没有改变,就像培训课程中的代码一样。

isinstance 是否不再被认为适合特殊类别,还是在更新中被删除?

【问题讨论】:

  • 如果你运行一个关于isinstance的小例子,你会发现它是否存在。 XD。
  • 您是否真的在 Visual Studio 中安装了 Python development tools?默认情况下不安装这些。所以我怀疑没有它你不会得到任何 Python 语法高亮。

标签: python isinstance


【解决方案1】:

是的,它仍然存在

Python 3.7.2 (tags/v3.7.2:9a3ffc0492, Dec 23 2018, 23:09:28) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license()" for more information.

>>> help(isinstance)
Help on built-in function isinstance in module builtins:

isinstance(obj, class_or_tuple, /)
    Return whether an object is an instance of a class or of a subclass thereof.

    A tuple, as in ``isinstance(x, (A, B, ...))``, may be given as the target to
    check against. This is equivalent to ``isinstance(x, A) or isinstance(x, B)
    or ...`` etc.

我没有看到 any indication in the docs 有删除此功能的愿望。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-03-27
    • 2018-12-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-07-29
    • 2020-04-22
    • 2018-12-16
    相关资源
    最近更新 更多