开发者

IPython mac terminal strange characters after using os.urandom

When using IPython, osx terminal and remoting into an ubuntu server. I noticed that if I try to encode and print the output of os.urandom(1) it will break the terminal and all input will start to look like this:

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

All input and output from the terminal continues to be displayed in that way even after ipython has been closed.

To replicate you can try:

import os
for i in xrange(10000)开发者_JAVA技巧:  
    try:  
        print os.urandom(1).encode('utf-8')
    except:
        pass

I have no use using a piece of code that does something like that. I'm just wondering why it would break the terminal.


Certain character sequences will send the terminal into alternate character set modes and the like. Run reset to fix this.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜