python 2需要 __init__.py文件

python 2需要 __init__.py文件

node2:/root/python3#python main.py 
Traceback (most recent call last):
  File "main.py", line 5, in 
    from utils.class_utils import *
ImportError: No module named utils.class_utils
node2:/root/python3#cd utils/
node2:/root/python3/utils#ls
class_utils.py  mul.py  __pycache__  utils.py
node2:/root/python3/utils#touch __init__.py
node2:/root/python3/utils#cd ..
node2:/root/python3#python main.py 
zyx
cba
node2:/root/python3#cat main.py 
import sys
import sys
sys.path.append(".")

from utils.class_utils import *

encoder = Encoder()
decoder = Decoder()

print(encoder.encode('xyz'))
print(decoder.decode('abc'))

 

你可能感兴趣的:(python,进阶)