【问题标题】:IPython mac terminal strange characters after using os.urandom使用os.urandom后的IPython mac终端奇怪字符
【发布时间】:2011-04-07 19:28:48
【问题描述】:

当使用 IPython、osx 终端和远程处理到 ubuntu 服务器时。我注意到,如果我尝试编码和打印 os.urandom(1) 的输出,它将破坏终端,所有输入将开始如下所示:

⎽⎽␤␌±┌▒␌␊@▒⎻⎻.⎻┌▒␌␊⎻┤┼␌␤.␌⎺└

即使在 ipython 关闭后,终端的所有输入和输出仍会继续以这种方式显示。

要复制你可以尝试:

import os
for i in xrange(10000):  
    try:  
        print os.urandom(1).encode('utf-8')
    except:
        pass

我没有用做这样的事情的一段代码。我只是想知道为什么它会破坏终端。

【问题讨论】:

    标签: python macos terminal ipython


    【解决方案1】:

    某些字符序列会将终端发送到备用字符集模式等。运行reset 来解决这个问题。

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-02-13
    • 1970-01-01
    • 1970-01-01
    • 2016-06-27
    • 1970-01-01
    • 2022-12-03
    • 1970-01-01
    相关资源
    最近更新 更多