看板 Python 關於我們 聯絡資訊
大家好,小弟我有一個A.py檔 裡面有自己定義f函數 但在B.py import A 時,都說找不到module 'A' has no attribute 'f' A有引用進去,但內容就是讀不到,請問是為甚麼呢? A.py def f(x): return x + 2 B.py import A result=A.f(5) module 'A' has no attribute 'f' 謝謝 -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 114.36.81.206 ※ 文章網址: https://www.ptt.cc/bbs/Python/M.1549125682.A.306.html HenryLiKing: print(dir(A))呢? 請問印出來之後要做甚麼步驟ㄋ~ 02/03 01:59
jiyu520: from b import f 02/03 02:09
jiyu520: 不知道是否是這問題? https://goo.gl/35WpbD 02/03 03:13
這個也不行~~謝謝 ※ 編輯: disney82231 (114.44.51.194), 02/03/2019 16:20:14
twoboy: __init__.py 02/04 00:25
alex13587: 我用Terminal重製你的code可行 02/04 15:23
alex13587: 你是用IDE的console嗎? 02/04 15:23