Python查看keywords关键字的方法和keywords列表

每种语言都有其特定的语法和keywords(关键字)Python也不例外,码笔记分享Python keywords关键字和keywords查询列表:

如何查看Python keywords

  • 1. 进入Python命令模式
  • 打开CMD命令行或者终端,执行命令:python

  • 2. 执行命令:help('keywords')即可查看Python的关键字
  • 示例:

    [root@mabiji ~]# python
    Python 2.7.10 (default, Oct  6 2017, 22:29:07)
    [GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.31)] on darwin
    Type "help", "copyright", "credits" or "license" for more information.
    >>> help('keywords')
    
    Here is a list of the Python keywords.  Enter any keyword to get more help.
    
    and                 elif                if                  print
    as                  else                import              raise
    assert              except              in                  return
    break               exec                is                  try
    class               finally             lambda              while
    continue            for                 not                 with
    def                 from                or                  yield
    del                 global              pass

    Python的keywords关键字列表

    如下:

    and elif if print
    as else import raise
    assert except in return
    break exec is try
    class finally lambda while
    continue for not with
    def from or yield
    del global pass

    2024年云服务器租用优惠价格,11月最新: