简体   繁体   English

我在输入命令的正确行上有语法错误

[英]I am having a syntax error on a correct line for input command

[it automatically detects it as a string` [它会自动将其检测为字符串`

this is the error这是错误

input_msg = input('enter message:-')
        ^
SyntaxError: invalid syntax`]

this is my code这是我的代码

import time
from cryptography.fernet import Fernet
from cryptography.hazmat.backends import default_backend
from cryptography.hazmat.primitives import hashes
from cryptography.hazmat.primitives.kdf.pbkdf2 import PBKDF2HMAC

password_provided = "password"  
password = password_provided.encode() 
salt = b'salt_' 
kdf = PBKDF2HMAC(
    algorithm=hashes.SHA256(),
    length=32,
    salt=salt,
    iterations=100000,
    backend=default_backend()
)

key = base64.urlsafe_b64encode(kdf.derive(password)

input_msg = input('enter message:-')

message = input_msg.encode()

time.sleep(15)

f = Fernet(key)

code = f.encrypt(message)

print(message)

i am using vs code and my python version is 3.7 i am unable to use input func and it automatically tells me that my variable is a string as the above image我正在使用 vs 代码,我的 python 版本是 3.7 我无法使用输入函数,它会自动告诉我我的变量是一个字符串,如上图

It looks like you are missing a closing bracket on the line above:看起来您在上面的行中缺少一个右括号:

key = base64.urlsafe_b64encode(kdf.derive(password) # need ) here

You're missing a paren on the line above.您在上面的行中缺少一个括号。 Should be:应该:

key = base64.urlsafe_b64encode(kdf.derive(password))键 = base64.urlsafe_b64encode(kdf.derive(密码))

On this line: key = base64.urlsafe_b64encode(kdf.derive(password) you need to add another ) at the end.在这一行: key = base64.urlsafe_b64encode(kdf.derive(password)你需要在最后添加另一个)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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