我正在写一个检查程序并遇到此错误,请问我需要帮助:这是我收到的错误 文件“ 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()
答案 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()