深度阅读

How to check the version of Python on your system in several ways

作者
作者
2023年08月22日
更新时间
8.08 分钟
阅读时间
0
阅读量

You can check the version of Python on your system in several ways. Here are a few methods:

  1. Using the command line: Open your command prompt or terminal and type python --version. This will output the current version of Python that is installed on your system.
  2. Using the platform module: You can import the platform module in Python and use its python_version() function to retrieve the Python version on your system. Here’s an example:
import platform
print(platform.python_version())
  1. In Python console, you can also use the sys module to obtain the version information about your Python installation, like this:
import sys
print(sys.version)

Whichever method you choose, you should get a string that contains the version of Python that is currently installed.

博客作者

热爱技术,乐于分享,持续学习。专注于Web开发、系统架构设计和人工智能领域。