其中最常用:
0 - 9 : 48~57
A - Z :65~90
a - z : 97~122
java中如何获取字符的ASCII码
java中使用Integer.valueOf(char c)方法可以直接获取一个字符的ASCII码,比如:public class ASCIITest { public static void main(String[] args) { char a='a'; char A='A'; int a_ascii=Integer.valueOf(a); int A_ascii=Integer.valueOf(A); System.out.println("字符"+a+"的ASCII码为:"+a_ascii); System.out.println("字符"+A+"的ASCII码为:"+A_ascii); System.out.println(A-2); System.out.println(A_ascii-a_ascii); } }
C++中如何获取字符的ASCII码
c++和java类似#include <iostream> #include <cstdio> using namespace std; int main() { char ch1 = 'a'; char ch2 = 'A'; cout << int(ch1) << endl; //将字符强转成整形数,也就是我们能看懂的十进制数 cout << int(ch2) << endl; return 0; }
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))
JavaScript中如何获取字符的ASCII码
var s = 'A'; console.log(s.charCodeAt(0)); // 65 console.log(String.fromCharCode(65)); // 'A' 'apple'.split('').forEach(function (c) { console.log(c + ': ' + c.charCodeAt(0)); });