我收到此代码的无效语法错误

时间:2019-06-03 10:27:14

标签: python-3.x

我正在写一个检查程序并遇到此错误,请问我需要帮助:这是我收到的错误 文件“ python1.py”,第14行     打印(f“登录成功e {email}和{password}”)                                                 ^ SyntaxError:语法无效

import requests
import multiprocessing
from multiprocessing.dummy import Pool



lock = multiprocessing.Lock()


class output(object):
    def screen(self, email, password, case):
        if case==True:
            lock.acquire()
            print(f"Login Success e {email} & {password}")
            print(f"""
                e = {email}
                p = {password}
                """, file=open("live.txt", "a"))
            lock.release()
        elif case==False:
            lock.acquire()
            print(f"Login Failed e {email} & {password}")
            lock.release()

1 个答案:

答案 0 :(得分:1)

您可能正在使用低于 3.6 的python版本,其中发布了fstrings。您的解决方案是更新还是依靠旧的可靠str.format方法:

class output(object):
    def screen(self, email, password, case):
        if case==True:
            lock.acquire()
            print("Login Success e {email} & {password}".format(email=email, password=password))
            print("""
                e = {email}
                p = {password}
                """.format(email=email, password=password), file=open("live.txt", "a"))
            lock.release()
        elif case==False:
            lock.acquire()
            print("Login Failed e {email} & {password}".format(email=email, password=password))
            lock.release()