我的代码在 Python 3.8 中完美运行,但是当我在相同的操作系统中切换到 Python 3.5,使用相同的代码和其他所有内容时,它开始抛出“SyntaxError:无效语法”。
这是错误,以及我认为与错误相关的代码部分:
Traceback (most recent call last):
File "pwb.py", line 390, in <module>
if not main():
File "pwb.py", line 385, in main
file_package)
File "pwb.py", line 100, in run_python_file
exec(compile(source, filename, 'exec', dont_inherit=True),
File ".\scripts\signbot.py", line 83
namespace: int
^
SyntaxError: invalid syntax
CRITICAL: Exiting due to uncaught exception <class 'SyntaxError'>
这是代码的一部分:
@dataclass
class RevisionInfo:
namespace: int
title: str
type: str
bot: bool
comment: str
user: str
oldRevision: Optional[int]
newRevision: int
timestamp: int
抱歉,如果问题标题不具体,但我无法让此代码在 Python 3.5 中运行。我将在其中运行此代码的服务器仅支持 Python 3.5,因此我需要使其与 3.5 一起使用。谢谢。