简体   繁体   中英

SyntaxError EOL while scanning string literal

I'm trying to use this Python one liner script:

python -c 'import hashlib,hmac; hash=raw_input("Hash > "); salt=raw_input("Salt > "); print "HMAC",hmac.new(salt,hash,hashlib.sha1).hexdigest().upper()'

And it gives me this error:

File "<string>", line 1
    'import
          ^
SyntaxError: EOL while scanning string literal

I'm using Windows 10 64bit and I'm working with ConEmu.

You can use single or double quotes within Python, but at the command-line terminal (cmd or Powershell) you have to use double quotes to enclose the argument you wish to send. Enclose it with double quotes, and use single quotes within it:

python -c "import hashlib,hmac; hash=raw_input('Hash > '); salt=raw_input('Salt > '); print 'HMAC',hmac.new(salt,hash,hashlib.sha1).hexdigest().upper()"

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