看板 Python 關於我們 聯絡資訊
請問一下,我從網路教學資源copy了以下的code #encrypt.py import random class Encrypt: def setCode(self): self.code = [chr(i) for i in range(97, 123)] random.shuffle(self.code) def getCode(self): return "".join(self.code) def toEncode(self): return "toEncode" def toDecode(self): return "toDecode" e = Encrypt() e.setCode() print() print(e.getCode()) print(e.toEncode()) print(e.toDecode()) print() ================= 然後我在Shell裡 import encrypt 它也的確會print出字串 但當我把encrypt.py改名為test.py,然後輸入 import test 它反而不動了 為什麼呢?謝謝 -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 60.248.17.41 ※ 文章網址: https://www.ptt.cc/bbs/Python/M.1469754008.A.5C0.html
daydream772: 是因為檔案沒放在同個資料夾嗎? 07/29 09:51
mindscold: 改名前後都在同一資料夾 沒有變動 07/29 10:09
micangela: 說不定是import 到內建的package了, 改檔名看看? 07/29 11:11
mindscold: !還真的有內建的叫test 換個名字就行了 謝謝! 07/29 11:18