美图齐众专注资阳网站设计 资阳网站制作 资阳网站建设
资阳网站建设公司服务热线:028-86922220

网站建设知识

十年网站开发经验 + 多家企业客户 + 靠谱的建站团队

量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决

Python 程序:查找字符串中所有字符的 ASCII 值

创新互联python教程:

写一个 Python 程序,用一个实际的例子找到字符串中总字符的 ASCII 值。

Python 程序查找字符串中总字符的 ASCII 值示例 1

这个 python 程序允许用户输入一个字符串。接下来,它使用 For 循环打印该字符串中的字符。这里,我们使用 For 循环来迭代字符串中的每个字符。在 For 循环中,我们使用 print 函数返回该字符串中所有字符的 ASCII 值。

提示:请参考 String 文章了解 String 的一切。也可以参考 Python 中的 ASCII 表一文来理解 ASCII 值。

# Python program to find ASCII Values of Total Characters in a String

str1 = input("Please Enter your Own String : ")

for i in range(len(str1)):
    print("The ASCII Value of Character %c = %d" %(str1[i], ord(str1[i])))

Python 程序获取字符串中的字符总数的 ASCII 值示例 2

这个 ASCII 值 python 程序同上。然而,我们只是将换成了同时换成了。

# Python program to find ASCII Values of Total Characters in a String

str1 = input("Please Enter your Own String : ")
i = 0

while(i < len(str1)):
    print("The ASCII Value of Character %c = %d" %(str1[i], ord(str1[i])))
    i = i + 1

Python 字符串 ASCII 值输出

Please Enter your Own String : Hello
The ASCII Value of Character H = 72
The ASCII Value of Character e = 101
The ASCII Value of Character l = 108
The ASCII Value of Character l = 108
The ASCII Value of Character o = 111

网页标题:Python 程序:查找字符串中所有字符的 ASCII 值
浏览地址:http://www.zsjierui.cn/article/cciodso.html

其他资讯