题目描述

将字符串中的大写字母转为小写

Leetcode-Easy 709. To Lower Case

思路

因为很简单,自己尽量想多种方法来尝试实现,本来想使用ASCII码实现(chr,ord)但是太麻烦了,想来想去有回归到下面两种:

代码实现

class Solution:
    def toLowerCase(self, str):
        """
        :type str: str
        :rtype: str
        """
        # solution 1
        # return str.lower()
        
        # solution 2
        temp=''
        for char in str:
            temp+=char.lower()
        return temp
        

相关文章:

  • 2021-09-09
  • 2022-01-28
  • 2021-12-08
  • 2022-12-23
  • 2022-02-15
  • 2022-12-23
  • 2021-06-05
  • 2021-11-19
猜你喜欢
  • 2021-11-22
  • 2021-10-23
  • 2021-10-10
  • 2022-12-23
  • 2022-01-15
  • 2022-02-03
  • 2021-10-08
相关资源
相似解决方案