gpt4 book ai didi

python - 为什么该字符串没有更改为大写

转载 作者:行者123 更新时间:2023-12-02 03:16:16 24 4
gpt4 key购买 nike

我写了一些代码

我不知道为什么我的字符串没有改变

虽然我使用的是上面的方法

def Input():
a = input('Type Anything\n')
print('\n')
a.upper()
print(a)
Input()

最佳答案

a.upper() 返回大写的字符串。所以你必须将其分配回变量 a。

def Input():
a = input('Type Anything\n')
print('\n')
a = a.upper()
print(a)
Input()

关于python - 为什么该字符串没有更改为大写,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56070007/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com