我似乎無法讓Python將子模塊導入到子文件夾中。當我嘗試從導入的模塊創建類的實例時,出現錯誤,但導入本身成功。這裏是我的目錄結構:無法從不同的文件夾導入Python
Server
-server.py
-Models
--user.py
這裏的server.py的內容:
from sys import path
from os import getcwd
path.append(getcwd() + "\\models") #Yes, i'm on windows
print path
import user
u=user.User() #error on this line
而且user.py:
class User(Entity):
using_options(tablename='users')
username = Field(String(15))
password = Field(String(64))
email = Field(String(50))
status = Field(Integer)
created = Field(DateTime)
的錯誤是: AttributeError的: '模塊'對象沒有屬性'用戶'
你能粘貼錯誤信息嗎? – 2009-01-19 03:55:38