【问题标题】:Why This String Not Changed to Uppercase [duplicate]为什么此字符串未更改为大写 [重复]
【发布时间】:2019-09-27 21:57:24
【问题描述】:

我写了一些代码

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

虽然我使用的是上层方法

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

【问题讨论】:

  • 对不起大家,我没有复制任何东西。我不知道是否有类似我的问题。对不起大家:)
  • 我投票重新打开它,因为它不是 stackoverflow.com/questions/6797984/… 的副本
  • 好的,打开它。我是新来的。 :)

标签: python string methods


【解决方案1】:

a.upper() 返回大写字符串。因此,您必须将其分配回变量 a。

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-01-05
    • 2015-07-15
    • 1970-01-01
    • 1970-01-01
    • 2012-03-04
    • 1970-01-01
    • 2020-02-29
    • 2014-02-04
    相关资源
    最近更新 更多