美文网首页
Python 练习实例60

Python 练习实例60

作者: loinue | 来源:发表于2022-05-13 16:10 被阅读0次

    来自菜鸟教程
    https://www.runoob.com/python/python-exercise-example60.html

    题目:计算字符串长度

    !/usr/bin/python

    -- coding: UTF-8 --

    sStr1 = 'strlen'
    print len(sStr1)

    直接使用len函数包裹住,其他语言,如vue计算长度是使用.length
    go 的话也是len(sStr1)

    评论区有给了另一个方法:
    sString = 'abcde'
    length = sString.len()
    print(length)
    同样是调用了len方法。

    字符串的处理常见的函数之后会常见到。

    相关文章

      网友评论

          本文标题:Python 练习实例60

          本文链接:https://www.haomeiwen.com/subject/mafuurtx.html