有人可以向我解释为什么下面的代码什么都没有打印出来吗?
class Deck(object):
def __init__(self, deck):
self.deck = getDeck(deck)
def getDeck(deck):
with open(deck, "rU") as csvfile:
cardReader = csv.DictReader(csvfile, delimiter=',')
newDeck = []
for row in cardReader:
for x in range(int(row['NumberOfCards'])):
newDeck.append(row)
removedKeyDeck = []
for x in range(len(newDeck)):
r = dict(newDeck[x])
del r['NumberOfCards']
removedKeyDeck.append(r)
return removedKeyDeck
playerDeck = Deck('deck1.csv')
print playerDeck
我正在尝试从deck1.csv
文件中创建一个套牌列表。我知道该getDeck
功能有效,但我没有class
正确使用结构。谁可以帮我这个事?