【问题标题】:How to convert upper case letters to lower case [duplicate]如何将大写字母转换为小写[重复]
【发布时间】:2011-12-13 07:18:20
【问题描述】:

我有一个脚本可以读取输入并列出它,但是我希望它将大写字母转换为小写字母,我该怎么做?

这就是我得到的

 for words in text.readlines():
    sentence = [w.strip(',.') for w in line.split() if w.strip(',.')]
    list.append(sentence)

【问题讨论】:

  • 如果你找到了strstripsplit方法,那么搜索upperlower有多难?
  • 请在来这里之前将这些内容输入谷歌,python 文档被点击 1 并且有正确的答案。记录在案,答案是thestring.lower()

标签: python


【解决方案1】:

您可以在文档的5.6.1. String Methods 部分找到更多与 Python 字符串相关的方法和函数。

w.strip(',.').lower()

【讨论】:

    【解决方案2】:

    str.lower() 将所有大小写字符转换为小写。

    【讨论】:

      【解决方案3】:

      要在 Python 中将字符串转换为小写,请使用类似这样的内容。

      list.append(sentence.lower())
      

      我在搜索“python 大写到小写”后的第一个结果中发现了这个。

      【讨论】:

        猜你喜欢
        • 2013-02-04
        • 1970-01-01
        • 2015-08-07
        • 2015-07-28
        • 1970-01-01
        • 2018-06-16
        • 1970-01-01
        • 2013-07-26
        • 2021-10-25
        相关资源
        最近更新 更多