Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
281 views
in Technique[技术] by (71.8m points)

python - Why does my code print "built-in method" and some hex numbers?

Here is my Key function:

def Key(message, decision):
    key = input("Input the key which will be used to encode the message.
".lower)
    n = 0
    for i in range(len(key)):
        if 64 < ord(key[n]) < 91:
            raise ValueError(key[n], "is a capital letter!")
        else:
            n = n+1
    Keycode(decision, message, key)

When I call it and input the message and press enter it comes up with:

built-in method lower of str object at 0x0150E0D0

What's wrong? How can I fix it?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

After .upper or .lower there has to be a closed pair of parentheses. You can put custom arguments in them but if you just want to capitalize the input leave them empty.

Example:

user=(input("Enter a letter:")).upper()

This will change case to upper.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...