def capital(message):
if message[0] >= 'a' or message[0] <= 'z':
return message[0].upper
for i in message:
if message[i - 1] in [".", "!", "?"] and message[i] != "":
return message[i].upper
elif message[i] == "i" and (message[i - 1] == " " or message[i + 1] in [" ", ".", "!", "?", "/"]):
return message[i].upper
return message
def main():
print(capital("you love you,i love you!mixuebingcheng tian/mimi"))
main()
结果:
<built-in method upper of str object at 0x7f96e6bafc70>
Process finished with exit code 0
目的是要把字符串里符合条件的字母大写,但是为什么这段代码运行出来是这个结果?