我刚开始使用Python创建模块,我想创建一个模块并导出结果。到目前为止,我拥有以下内容,并且将模块命名为Card_module
:
from random import shuffle
def Cards(deck,colour):
for item in colour:
return (item,deck)
def Vdeckk():
colour=['RED', 'YELLOW', 'BLACK']
deck=[]
deck=[Cards(value,colour)for value in range(1,11)]
return (deck)
if __name__=='__main__':
Vdeckk()
当我运行import Card_module
然后Card_module.Vdeckk()
时,我收到以下错误消息:
Traceback (most recent call last):
File "<ipython-input-61-8a304a818b2c>", line 1, in <module>
Card_module.Vdeckk()
File "C:\Users\mnazari\AppData\Local\Continuum\anaconda3\lib\site-packages\IPython\core\displayhook.py", line 258, in __call__
self.update_user_ns(result)
File "C:\Users\mnazari\AppData\Local\Continuum\anaconda3\lib\site-packages\IPython\core\displayhook.py", line 196, in update_user_ns
if result is not self.shell.user_ns['_oh']:
KeyError: '_oh'