当我运行以下代码时:
while start == "yes":
player1name = input("Player 1 what shall your character be called?")
player2name = input("Player 2 what shall your character be called?")
player1strength=print("Player 1,your strength score is :)", random.randint(1,7))
player2strength=print("Player 2,your strength score is :)", random.randint(1,7))
strengthdifference =(int(player1strength) - int(player2strength))
if strengthdifference<0:
strengthdifference=player2strength-player1strength
strengthdifference=strengthdifference/5
player1skill=int(input("Player 1,enter your skill score :)"))
player2skill=int(input("Player 2,enter your skill score :)"))
skilldifference=player1skill-player2skill
我得到这个追溯:
File "C:\Computing\A453 Assessment\Task 3\main.py", line 18, in <module>
strengthdifference =(int(player1strength) - int(player2strength))
TypeError: int() argument must be a string, a bytes-like object or a number, not 'NoneType'
我做错了什么?我该如何修复错误?
答案 0 :(得分:1)
错误表明他们的...
WebClientResponse webClientResponse;
if (!string.IsNullOrWhiteSpace(ForceSecurityProtocol))
{
using (var isolated = new Isolated<WebClient>())
{
webClientResponse = isolated.Value.GetResponse(url, ForceSecurityProtocol);
}
}
else
{
webClientResponse = _webClient.GetResponse(url);
}
...
或player1strength
(或可能两者)都是player2strength
,None
不能将其作为参数。它可能 两者,因为您要将调用结果分配给int()
。
也许它确实说了一些关于*强度差异的信息,但由于你没有提供细节,我无法回应。