It's because hello
is the name of function you've defined, thus print(hello, name)
prints both the function object, and the string variable. If you want to print hello Bob !!!!!
, use print('hello', name)
instead.
Print Program works, but prints extra letters/numbers
-
04-08-2022 - |
문제
I am trying to get a simple program to take command line arguments and print them out. Any name plus a character string of explanation marks. example: Bob !!!!
import sys
def hello(name):
name = name + "!!!!"
print(hello,name)
def main():
hello(sys.argv[1])
main()
It correctly prints out Bob!!!!, but with also some other stuff:
function hello at 0x7f69465145f0 Bob!!!! with < > around the whole thing except Bob!!!!
I am not sure why it will not simply print out, Bob!!!!, normally without the other stuff.
Also, the mix of number/letters within the < > changes every time I run it. The function hello at and Bob!!!! stays the same.
해결책
다른 팁
Try
def hello(name):
print('Hello, '+name+'!!!')
제휴하지 않습니다 StackOverflow