社区所有版块导航
Python
python开源   Django   Python   DjangoApp   pycharm  
DATA
docker   Elasticsearch  
aigc
aigc   chatgpt  
WEB开发
linux   MongoDB   Redis   DATABASE   NGINX   其他Web框架   web工具   zookeeper   tornado   NoSql   Bootstrap   js   peewee   Git   bottle   IE   MQ   Jquery  
机器学习
机器学习算法  
Python88.com
反馈   公告   社区推广  
产品
短视频  
印度
印度  
Py学习  »  Python

Python 3中字符串大写for循环的复杂性

Harsh Pradhan • 5 年前 • 1556 次点击  

我正在尝试使用以下技巧将字符串中的单词大写:

 def solve(s):
     if len(s)>0 and len(s)<1000:
         li= s.split(" ")

         for i in li:
             i= i.capitalize()

     return " ".join(li)

def solve(s):
    if len(s)>0 and len(s)<1000:
        li= s.split(" ")

        for i in range(len(li)):
            li[i]= li[i].capitalize()

    return " ".join(li)
Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/57248
 
1556 次点击  
文章 [ 2 ]  |  最新文章 5 年前