python字符ascii_Python程序打印字符的ASCII值

python字符ascii

Given a character, and we have to find its ASCII code.

给定一个字符,我们必须找到它的ASCII码。

Python中字符的ASCII值 (ASCII value of character in Python)

In python, to get an ASCII code of a character, we use ord() function. ord() accepts a character and returns the ASCII value of it.

python中,要获取字符的ASCII码,我们使用ord()函数。 ord()接受一个字符并返回其ASCII值。

Syntax:

句法:

    ord(character);

Example:

例:

    Input:
    char_var = 'A'

    Function call:
    ord(char_var)

    Output:
    65

Python code to find ASCII value of a character

Python代码查找字符的ASCII值

# python program to print ASCII
# value of a given character

# Assigning character to a variable
char_var = 'A'
# printing ASCII code
print("ASCII value of " + char_var + " is = ", ord(char_var))

char_var = 'x'
# printing ASCII code
print("ASCII value of " + char_var + " is = ", ord(char_var))

char_var = '9'
# printing ASCII code
print("ASCII value of " + char_var + " is = ", ord(char_var))

Output

输出量

ASCII value of A is =  65
ASCII value of x is =  120
ASCII value of 9 is =  57


翻译自: https://www.includehelp.com/python/print-ascii-value-of-a-character.aspx

python字符ascii


http://www.niftyadmin.cn/n/1255379.html

相关文章

Redis学习笔记(三):Redis常见命令

KEY相关命令: DEL key : 该命令用于key存在时删除keyDUMP key : 序列化给定key,并返回被序列化的值EXISTS key :检测key是否存在EXPIRE key seconds : 为给定的key设置过期时间EXPIREAT key timestamp :…

atoi的简易实现

atoi() ——字符串转数字 //暂时仅考虑了十进制和十六进制 int atoi(const char * buf) {int value 0;int base 10;int i 0;if (buf[0] 0 && buf[1] x){base 16;i 2;}while (buf[i]){int tmp;if (buf[i] < 9 && buf[i] > 0){tmp buf[i] -0;}else{t…

RISC-V平台的汇编指令解析

csrr a0, 0xF14 //把0xF14的值读入到a0中 andi a1, a0, 0x1f //把a0 和0x1F按位与运算后存储到a1中 srli a0, a0, 5 //将高位移动到低位,覆盖a0 (SLLI是逻辑左移(0被移入低位); SRLI是逻辑右移(0被移入高位);SRAI是算术右移(原来的符号位被复制到空出的高位中)) li …

海报PLA (HYSBZ - 1113)单调栈模板

N个矩形,排成一排. 现在希望用尽量少的矩形海报Cover住它们. Input 第一行给出数字N,代表有N个矩形.N在[1,250000] 下面N行,每行给出矩形的长与宽.其值在[1,1000000000]2 1/2 Postering Output 最少数量的海报数. Sample Input5 1 21 32 22 51 4 Sample Output 4 先解释下题意&…

Java中从String到Float的转换

Given a string and we have to convert it into a float. 给定一个字符串&#xff0c;我们必须将其转换为浮点数。 Java conversion from String to Float Java从String转换为Float To convert a String to Float, we can use the following methods of Float class (see th…

django基础篇06-ModelForm操作及验证

本文内容主要来自银角大王的博客 学习大纲&#xff1a; 一、ModelForm  二、Ajax- 原生&#xff08;jQuery&#xff09;- 伪Ajax操作三、文件上传&#xff08;预览&#xff09;- Form提交- Ajax文件上传四、 图片验证码 session 五、CKEditor、UEEditor、TinyEditor、KindEd…

斐波那契数列c ++递归_找到第N个斐波那契数| C ++

斐波那契数列c 递归Problem: Compute the Nth Fibonacci number 问题&#xff1a;计算第N 个斐波那契数 You are given a number N. You have to find the Nth Fibonacci number. 0th Fibonacci number is 0 and first Fibonacci number is 1. 给您一个数字N。您必须找到第N 个…

idea关闭标签快捷键修改----兼 常用实用快捷键

还有一个快捷键: 自动补全返回值 : ctrl alt valt enter: 自动添加未定义的方法idea 原本的关闭快捷键是&#xff1a; ctrl F4&#xff0c;但是不好用&#xff0c;谁的手指伸这么长修改这个快捷键&#xff0c;即 将 ctrl W 也修改成关闭快捷键方法: 按住 ctrl alt s, 找…