我记得在Python3.5文档中,我读过如何在Python交互提示符上更改>>>,例如调用help()如何将其更改为help>.

但由于某种原因,当我回go 试着回忆时,我就是找不到它的说明.有人知道这是否可能吗?

推荐答案

你记得没错.

它位于sys模块(sys.ps1和sys.ps2)中:

Strings specifying the primary and secondary prompt of the interpreter. These are only defined if the interpreter is in interactive mode. Their initial values in this case are '>>> ' and '... '. If a non-string object is assigned to either variable, its str() is re-evaluated each time the interpreter prepares to read a new interactive command; this can be used to implement a dynamic prompt.

例如:

   >>> import sys
   >>> sys.ps1 = "3.5>>> "
   3.5>>> sys.ps2 = "3.5... "
   3.5>>>

Python-3.x相关问答推荐

海象表达可以放在方括号中而不是括号中吗?

替换Pandas中组下的列值

如何通过Pandas为不同的列集垂直设置列数据?

如何从枚举中获取某个值?

按长度和字母数字对Pandas 数据帧列进行排序

当条件第一次出现时将行标记为True,如果按顺序重复则标记为False

Python VS Code 自动导入路径包含 src

命名空间前缀无效

计算文档中所有关键字(单词和多词)出现的频率

Python3:是否可以将变量用作函数调用的一部分

来自嵌套字典的完整地址

获取字符串中的两个工作日之间的差异

Pygame 错误地渲染等距图像

如何将虚拟变量列转换为多列?

Python socket.error: [Errno 13] 权限被拒绝

如何通过python打开文件

使用逗号时,除了处理程序中的语法无效

在 Python 3 中获取所有超类

PIL 在图像上绘制半透明方形覆盖

有没有一种标准方法来确保 python 脚本将由 python2 而不是 python3 解释?