Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/306.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python:def uu init(self,config_path:str,*args,**kwargs):^SyntaxError:无效语法_Python - Fatal编程技术网

Python:def uu init(self,config_path:str,*args,**kwargs):^SyntaxError:无效语法

Python:def uu init(self,config_path:str,*args,**kwargs):^SyntaxError:无效语法,python,Python,我在mac上运行Python3.6.5,代码所有者告诉我把它带到这里,因为他说这是某种本地错误。不确定为什么会发生这种情况: Traceback (most recent call last): File "/Users/User/Downloads/Bot/Python/launcher.py", line 2, in <module> from catcher import Poke File "/Users/User/Downloads/Bot/Python/catch

我在mac上运行Python3.6.5,代码所有者告诉我把它带到这里,因为他说这是某种本地错误。不确定为什么会发生这种情况:

Traceback (most recent call last):
File "/Users/User/Downloads/Bot/Python/launcher.py", line 2, in <module>
    from catcher import Poke
File "/Users/User/Downloads/Bot/Python/catcher.py", line 11
    def __init__(self, config_path: str, *args, **kwargs):
                                       ^
SyntaxError: invalid syntax

编辑:添加更多代码并重新组织代码缩进,以匹配终端读数和键入的代码。还添加了一个扩展描述

我假设您没有使用Python 3.5+运行程序

由于您的代码从似乎仅与Python 3兼容的模块导入,因此会引发SyntaxError

config\u path:str
)是Python 3.5中的新功能-通过键入以下内容确保您正在运行该Python版本:

$ python3 --version
Python 3.6.2
在你的终点站

确保您也在这样执行程序:

$ python3 launcher.py

它背后的代码是什么?您可能缺少一个右括号
您需要
\uuuuu init\uuuuu
下的东西,可能需要一个
通行证?否则,您需要粘贴更多的代码,顺便问一下,您当前运行的不是什么版本?或者,您是使用Python 2还是Python 3运行此代码?
config\u path:str
仅是python 3语法。这是一段很长的代码,所有者让我在这里询问。错误回溯显示
def\uuu init\uu
没有缩进,这与您发布的代码不符。请编辑以向我们显示确切的代码和错误消息。我正在运行python 3.6。5@abccd它指向“:”就在“str,*args,**kwargs”之前“@CedricWong您是如何执行python文件的?你是在键入
pythonlauncher.py
还是
python3launcher.py
?我通过python3.6.5launcher应用程序启动它
$ python3 launcher.py