简体   繁体   中英

Invalid syntax error in python script

When trying to run a python script with cmd it gives me this error "Invalid syntax".

Here's the code, and the invalid error is in line 3 "raise bla bla"

def make_chunk(tag, data):
    if len(tag) != 4:
      raise â€کYo!They call it “FourCCâ€‌ for a reason.’
    ret = struct.pack(â€ک>L’, len(data) + 8)
    ret += tag
    ret += data
    return ret

Your code editor replaced single ( ' - U+0027 APOSTROPHE ) and double ( " - U+0022 QUOTATION MARK ) ASCII quotes with 'fancy' quotes, specifically:

You then saved the file as UTF-8, and tried to have Python run it.

Python doesn't support anything but the ASCII quotes for strings, so an exception was raised, and because your console is configured as Windows codepage 1256 you see the weird Mojibake output:

>>> print u'\u2018 - \u2019 - \u201C - \u201D'
‘ - ’ - “ - ”
>>> u'\u2018 - \u2019 - \u201C - \u201D'.encode('utf8')
'\xe2\x80\x98 - \xe2\x80\x99 - \xe2\x80\x9c - \xe2\x80\x9d'
>>> print u'\u2018 - \u2019 - \u201C - \u201D'.encode('utf8').decode('cp1256')
â€ک - ’ - “ - â€‌

Use a better (code) editor or tell the current editor to not replace simple quotes with fancy quotes.

It doesn't answer your question, but it will solve your problem.

Download the exploit from github instead of exploit-db

https://gist.github.com/tfairane/fedb4881945bab998504#file-stagefright_cve-2015-1538-1_exploit-py-L6

Your welcome

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