Python标准库学习--->2、内置常量

内置常量
有少数的常量存在于内置命名空间中。 它们是:
1>False:bool 类型的假值。

2>True:bool 类型的假值。

3>None:NoneType 类型的唯一值。

4>NotImplemented:双目运算特殊方法(如 eq(), lt(), add(), rsub() 等)应返回的特殊值,用于表示运算没有针对其他类型的实现;也可由原地双目运算特殊方法(如 imul(), iand() 等)出于同样的目的而返回。 它不应被作为布尔值来解读。

5>Ellipsis:与省略号文字字面 “…” 相同。

6>debug:如果 Python 没有以 -O 选项启动,则此常量为真值。

由 site 模块添加的常量
site 模块(在启动期间自动导入,除非给出 -S 命令行选项)将几个常量添加到内置命名空间。 它们对交互式解释器 shell 很有用,并且不应在程序中使用。

1>quit(code=None),exit(code=None):当打印此对象时,会打印出一条消息,例如“Use quit() or Ctrl-D (i.e. EOF) to exit”,当调用此对象时,将使用指定的退出代码来引发 SystemExit。

>>> print(quit)
Use quit() or Ctrl-Z plus Return to exit
>>> print(exit)
Use exit() or Ctrl-Z plus Return to exit
>>> 

2>copyright,credits:打印或调用的对象分别打印版权或作者的文本。

>>> print(copyright)
Copyright (c) 2001-2020 Python Software Foundation.
All Rights Reserved.

Copyright (c) 2000 BeOpen.com.
All Rights Reserved.

Copyright (c) 1995-2001 Corporation for National Research Initiatives.
All Rights Reserved.

Copyright (c) 1991-1995 Stichting Mathematisch Centrum, Amsterdam.
All Rights Reserved.
>>> print(credits)
    Thanks to CWI, CNRI, BeOpen.com, Zope Corporation and a cast of thousands
    for supporting Python development.  See www.python.org for more information.
>>> 

3>license:当打印此对象时,会打印出一条消息“Type license() to see the full license text”,当调用此对象时,将以分页形式显示完整的许可证文本(每次显示一屏)。

>>> print(license)
Type license() to see the full license text
>>> 
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值