简体   繁体   中英

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):  
    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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM