【问题标题】:Capitalize only first word and leave rest as it is python [duplicate]仅大写第一个单词并保留其余部分,因为它是python [重复]
【发布时间】:2021-09-04 21:11:04
【问题描述】:

我有一个词“biPAP”和其他一些类似的词我只想要使用 python 的“BiPAP”之类的输出。

【问题讨论】:

  • 到目前为止你尝试了什么?
  • 我试过 tittle() 但它只大写第一个单词并输出 Bipap
  • 我确定python中有将字符变成大写的函数
  • 这样做 - s = s[:1].upper() + s[1:]

标签: python-3.x


【解决方案1】:
word = 'testWord'    
word = word[0].upper() + word[1:]

【讨论】:

    猜你喜欢
    • 2019-12-27
    • 1970-01-01
    • 1970-01-01
    • 2012-04-12
    • 2023-04-04
    • 2017-04-04
    • 2016-10-20
    • 2013-02-21
    • 2017-01-04
    相关资源
    最近更新 更多