寫一個 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))
原創文章,作者:簡單一點,如若轉載,請註明出處:https://www.506064.com/zh-tw/n/129039.html