我有名稱的模塊爲「downloadflat-modular.py」,蟒蛇無法導入該模塊的Python不接受進口模塊名「 - 」
Python 3.4.0 (default, Apr 11 2014, 13:05:11)
[GCC 4.8.2] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import downloadflat-modular
File "<stdin>", line 1
import downloadflat-modular
^
SyntaxError: invalid syntax
>>> from downloadflat-modular import *
File "<stdin>", line 1
from downloadflat-modular import *
^
SyntaxError: invalid syntax
>>>
這是一個限制?
uname -a
Linux ubuntu 3.16.0-30-generiC#40~14.04.1-Ubuntu SMP Thu Jan 15 17:43:14 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
_這是限制嗎?_是的。 Python不能說「downloadflat-modular」就是一個標識符。只要將它改爲使用'_'即可。 –