我无法在python中使用我的一个函数来工作。我的功能代码如下:
type transaction struct {
res Response // Create this type also
req Request // Create this type also
}
func NewTransaction(w http.ResponseWriter, req *http.Request) *transaction{}
Log := make(chan transaction, 100)
go func{
// Read from channel and log the info however you want.
}()
func indexHandler(w http.ResponseWriter, req *http.Request) {
tx := NewTransaction(w, req) // Struct with the request and response
defer func() {
Log <- tx
}()
/*
Handle request here
*/
// Update request and response
Request.Body = body
}
函数调用是:
def checkBlackjack(value, pot, player, wager):
if (value == 21):
print("Congratulations!! Blackjack!!")
pot -= wager
player += wager
print ("The pot value is $", pot)
print ("Your remaining balance is $",player)
return (pot, player)
我得到的错误是:
potValue, playerBalance = checkBlackjack(playerValue, potValue, playerBalance, wager)
由于错误导致无法迭代,我不知道如何将其与使用if条件联系起来。
真的很感激任何帮助。谢谢!
答案 0 :(得分:3)
如果满足函数中的条件,您只返回一些内容,否则函数默认返回None
,然后尝试将None
解包为两个值(您的变量)
答案 1 :(得分:1)
以下是此问题的MCVE:
>>> a, b = None
Traceback (most recent call last):
File "<pyshell#2>", line 1, in <module>
a, b = None
TypeError: 'NoneType' object is not iterable
此时,问题应该清楚。如果没有,可以在手册中查找多个作业。