如何在同一文件夹/目录中导入库?
我尝试使用this answer / solution,但Python抛出此错误:
user@computer:~/program$ python3 __init__.py
File "__init__.py", line 102
import .get_len
^
SyntaxError: invalid syntax
user@computer:~/program$ pwd
/home/user/program
Python 3.5.3 (default, Sep 27 2018, 17:25:39)
[GCC 6.3.0 20170516] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> exit()
注意:user
和computer
不是真实姓名。
100| if args.mode == 'get-len':
101| try:
102| import .get_len
103| except ImportError as error:
104| msg = str(error)
program_folder
| __init__.py
| get_len.py
| get_chart.py
| get_geo.py