python-获取字符串长度

1. 获取字符串长度

  • len()内建函数:计算字符串的长度。

  • 语法格式:len(string)

  • 示例代码

    str1 = "hello"
    print(len(str1))
    

2. 案例

  • len获取长度

    #!/usr/bin/env python3
    # _*_ coding: utf-8 _*_
    # Author:shichao
    # File: .py
    
    str1 = "hello"
    print(len(str1))
    
posted @ 2022-12-26 11:29  七月流星雨  阅读(252)  评论(0编辑  收藏  举报