Python控制台名称自定义
通常Python控制台看起来像这样:
>>> command
有没有办法让它看起来像这样:
SomeText>>> command
Usually the Python console looks like this:
>>> command
Is there a way to make it look like:
SomeText>>> command
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您还可以在 PYTHONSTARTUP 环境变量中更改此设置。
例如(这不安全),将以下内容放入脚本中的某个位置并将 PYTHONSTARTUP 设置为指向该脚本。
当然,您可以将上面的最后一行更改为您想要的任何内容。
You can also change this in the PYTHONSTARTUP environment variable.
For example (this is not secure), put the following in a script somewhere and set PYTHONSTARTUP to point at that script.
Of course, you could change the last line above to anything you want.
您可以尝试
(或按照其他答案的建议使用
getpass.getuser()
)在更正后的版本中,当然更容易:
You could try
(or
getpass.getuser()
as suggested by the other answer)In the corrected version, it's even easier, of course:
IPython 提供了设置复杂提示的便捷方法,如此处。
IPython provides convenient way of setting sophisticated prompts as described here.