开发者社区> 问答> 正文

Python 判断字符串长度

Python 判断字符串长度

展开
收起
游客ejnn55cgkof5g 2020-02-14 18:27:38 2656 0
1 条回答
写回答
取消 提交回答
  • str = "runoob"
    print(len(str))
    执行以上代码输出结果为:
    
    6
    实例 2:使用循环计算
    def findLen(str): 
        counter = 0
        while str[counter:]: 
            counter += 1
        return counter 
      
    str = "runoob"
    print(findLen(str))
    执行以上代码输出结果为:
    
    6
    2020-02-14 18:27:59
    赞同 展开评论 打赏
问答分类:
问答地址:
问答排行榜
最热
最新

相关电子书

更多
From Python Scikit-Learn to Sc 立即下载
Data Pre-Processing in Python: 立即下载
双剑合璧-Python和大数据计算平台的结合 立即下载