我使用Pycharm和Python 3.4在不同的服务器上执行自己编写的脚本。我的代码中有使用类型提示。现在,有人在Python 3.5安装上执行了我的代码,但是遇到了类型提示的语法错误。我并没有“故意”在Python 3.4中使用任何类型提示模块,即我没有使用typing模块。
def run(iargs) -> int:
^ syntax error
Python 3.4是否可能没有读取这些标签,而3.5会读取?
编辑
我进行了以下测试
Python 3.4.3 (default, Oct 28 2016, 10:12:53)
[GCC 4.8.4] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> def Add(r,l) -> int:
... return int(r + l)
...
>>> Add(3,5)
8
>>>
Python 3.5.2 (default, Nov 17 2016, 17:05:23)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> def Add(r,l) -> int:
... return int(r + l)
...
>>> Add(3,5)
8
关于 Python 版本如 3.4 或 3.5 并没有问题,但当我运行脚本时,会出现以下错误:
File "test.py", line 235
def run(iargs) -> int:
^
SyntaxError: invalid syntax
问候
typing
模块就可以了,现在它已经可以正常运行了,没有任何语法错误。 - Edw590