在使用pip安装cloudstorage模块之后,当我尝试导入时,得到以下错误。
import cloudstorage
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/keshaw/vinv/lib/python2.7/site-packages/cloudstorage/__init__.py", line 56
def get_driver(driver: DriverName) -> Drivers:
^
SyntaxError: invalid syntax我也尝试过安装不同的版本,但是同样的问题
发布于 2017-10-30 14:58:37
你在使用python3吗?似乎有语法错误。python2中不提供Typing。Python2:
Python 2.7.13 (default, Jan 19 2017, 14:48:08)
[GCC 6.3.0 20170118] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> def get_driver(driver: str) -> str:
File "<stdin>", line 1
def get_driver(driver: str) -> str:
^
SyntaxError: invalid syntax
>>> Python3:
Python 3.5.3 (default, Sep 14 2017, 22:58:41)
[GCC 6.3.0 20170406] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> def get_driver(driver: str) -> str:
... 在python3中,您的语法应该是有效的:)
https://stackoverflow.com/questions/47009532
复制相似问题