欢迎您 本站地址:  
返回首页   返回编程教学   颜色值在线转换  卡通音效  男生头像背影  端游源码  国际电话区号大全  北齐书  学习JSON  学习SQLite 

Python 判断字符串长度

Document 对象参考手册 Python3 实例

给定一个字符串,然后判断该字符串的长度。

实例 1:使用内置方法 len()

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

Document 对象参考手册 Python3 实例

小库提示

扫描下方二维码,访问手机版。