Jestem nowy w Pythonie i napisałem ten prosty skrypt:„<method> przyjmuje żadnych argumentów (1 podano)”, ale dałem żaden
#!/usr/bin/python3
import sys
class Hello:
def printHello():
print('Hello!')
def main():
helloObject = Hello()
helloObject.printHello() # Here is the error
if __name__ == '__main__':
main()
Kiedy go uruchomić (./hello.py
) pojawia się następujący komunikat o błędzie :
Traceback (most recent call last): File "./hello.py", line 13, in <module> main() File "./hello.py", line 10, in main helloObject.printHello() TypeError: printHello() takes no arguments (1 given)
Dlaczego Python myśleć dałem printHello()
argumentu, a ja z pewnością nie zrobił? Co zrobiłem źle?
możliwe duplikat [Błąd kompilatora Pythona x przyjmuje żadnych argumentów (1 podano)] (http://stackoverflow.com/questions/4445405/python-compiler-error -x-takes-no-arguments-1-given) – IanAuld