[問題] 關於import的檔名?
請問一下,我從網路教學資源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
推
07/29 09:51, , 1F
07/29 09:51, 1F
→
07/29 10:09, , 2F
07/29 10:09, 2F
→
07/29 11:11, , 3F
07/29 11:11, 3F
→
07/29 11:18, , 4F
07/29 11:18, 4F
Python 近期熱門文章
PTT數位生活區 即時熱門文章