我记得在 Python 3.5 文档中阅读过如何更改 Python 交互式提示上的 >>>
,例如调用 help()
将如何更改它到 help>
.
但由于某种原因,当我回去尝试内存时,我就是找不到它的说明。有谁知道这是否可能?
最佳答案
你没记错。
它在 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 - 更改 Python 交互提示 ">>>",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33683744/