将一个函数分配给一个类而不调用该函数?

时间:2019-05-01 19:34:09

标签: python

当我将函数分配给变量时,它将运行该函数。

我试图将函数更改为func而不是func(),但是我不知道从哪里开始。


def deck():
  global card
  ranks = ["Q", "K", "J", "10","9", "8",
          "7", "6","5","4","3","2","A"]

  suits = ["Clubs", "Diamonds", "Hearts", "Spades"]

  for i  in range(56): 
    for i in (ranks):
        rank = random.choice(ranks)
        suit = random.choice(suits)
        card_loop = card_loop + 1

    card = ("{} of {}").format(rank, suit)
  print (card)

hit = deck

#hit or stand class

stand = (0)

class hit_stand_class:
  def __init__(self, hit, stand):
    self.hit = print (card)
    self.stand = stand


hit_stand = hit_stand_class(hit, stand)

hit_stand.stand

`````````````
and it runs function()
````````````

0 个答案:

没有答案