首页 > 编程知识 正文

Python 程序:计算字符串长度

时间:2023-11-24 15:33:40 阅读:308886 作者:DHGW

写一个 Python 程序,用实例找到字符串长度。

Python 程序查找字符串长度示例 1

程序使用镜头功能找到字符串长度。

请参考字符串文章,了解 Python 中关于它们的一切。

str1 = "Tutorial Gateway"

print("Total Length of a Given String = ", len(str1))
Total Length of a Given String =  16

Python 程序查找字符串长度示例 2

这个 python 程序和第一个例子一样。但是,这一次,我们允许用户输入自己的字符串。

str1 = input("Please enter your own String : ")

print("Total Length of a Given String = ", len(str1))

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。