例如,当我键入NICK和HASLO时,我有以下错误:
Traceback (most recent call last):
File "G:/Wszystko/WONSZ/test.py", line 21, in <module>
nick = nick()
TypeError: 'str' object is not callable
当我输入nick和haslo时,它工作了,但不是 那我该怎么做才能解决呢? 代码如下:
x = int
y = int
def nick():
print ("Podaj swoj nick: ",end=' ')
nick = input()
return nick
def haslo():
print ("Podaj swoje haslo: ",end=' ')
haslo = input()
return haslo
print ("Witaj!!!")
while True:
x = 0
y = 0
nick = nick()
haslo = haslo()
if nick == "nick":
x += 1
if haslo == "haslo":
y += 1
if x==0:
print("Nick bledny")
if y == 0:
print("Haslo bledne")
if x==1 and y==1:
break
print("Zalogowano")
我能做些什么来解决这个问题?你知道吗
重复变量和函数名可能很危险。在您的例子中,代码变得凌乱,Python无法正确地判断您引用的是变量还是函数。你知道吗
在这里,我更改了变量的名称。不仅有效,而且更容易阅读:
相关问题 更多 >
编程相关推荐