python脚本代码大全_ASCII表(python生成脚本)

ascii表

hex dec character cstyle

0x00 0 \0 (终止符) '\0'

0x01 1 \x1 '\x1'

0x02 2 \x2 '\x2'

0x03 3 \x3 '\x3'

0x04 4 \x4 '\x4'

0x05 5 \x5 '\x5'

0x06 6 \x6 '\x6'

0x07 7 \x7 '\x7'

0x08 8 \b (退格符) '\x8'

0x09 9 \t (制表符) '\t'

0x0a 10 \n (换行符) '\n'

0x0b 11 \xb '\xb'

0x0c 12 \xc '\xc'

0x0d 13 \r (回车符) '\r'

0x0e 14 \xe '\xe'

0x0f 15 \xf '\xf'

0x10 16 \x10 '\x10'

0x11 17 \x11 '\x11'

0x12 18 \x12 '\x12'

0x13 19 \x13 '\x13'

0x14 20 \x14 '\x14'

0x15 21 \x15 '\x15'

0x16 22 \x16 '\x16'

0x17 23 \x17 '\x17'

0x18 24 \x18 '\x18'

0x19 25 \x19 '\x19'

0x1a 26 \x1a '\x1a'

0x1b 27 \x1b '\x1b'

0x1c 28 \x1c '\x1c'

0x1d 29 \x1d '\x1d'

0x1e 30 \x1e '\x1e'

0x1f 31 \x1f '\x1f'

0x20 32 space(空格) ' '

0x21 33 ! '!'

0x22 34 " '"'

0x23 35 # '#'

0x24 36 $ '$'

0x25 37 % '%'

0x26 38 & '&'

0x27 39 ' "'"

0x28 40 ( '('

0x29 41 ) ')'

0x2a 42 * '*'

0x2b 43 + '+'

0x2c 44 , ','

0x2d 45 - '-'

0x2e 46 . '.'

0x2f 47 / '/'

0x30 48 0 '0'

0x31 49 1 '1'

0x32 50 2 '2'

0x33 51 3 '3'

0x34 52 4 '4'

0x35 53 5 '5'

0x36 54 6 '6'

0x37 55 7 '7'

0x38 56 8 '8'

0x39 57 9 '9'

0x3a 58 : ':'

0x3b 59 ; ';'

0x3c 60 < '<'

0x3d 61 = '='

0x3e 62 > '>'

0x3f 63 ? '?'

0x40 64 @ '@'

0x41 65 A 'A'

0x42 66 B 'B'

0x43 67 C 'C'

0x44 68 D 'D'

0x45 69 E 'E'

0x46 70 F 'F'

0x47 71 G 'G'

0x48 72 H 'H'

0x49 73 I 'I'

0x4a 74 J 'J'

0x4b 75 K 'K'

0x4c 76 L 'L'

0x4d 77 M 'M'

0x4e 78 N 'N'

0x4f 79 O 'O'

0x50 80 P 'P'

0x51 81 Q 'Q'

0x52 82 R 'R'

0x53 83 S 'S'

0x54 84 T 'T'

0x55 85 U 'U'

0x56 86 V 'V'

0x57 87 W 'W'

0x58 88 X 'X'

0x59 89 Y 'Y'

0x5a 90 Z 'Z'

0x5b 91 [ '['

0x5c 92 \ '\\'

0x5d 93 ] ']'

0x5e 94 ^ '^'

0x5f 95 _ '_'

0x60 96 ` '`'

0x61 97 a 'a'

0x62 98 b 'b'

0x63 99 c 'c'

0x64 100 d 'd'

0x65 101 e 'e'

0x66 102 f 'f'

0x67 103 g 'g'

0x68 104 h 'h'

0x69 105 i 'i'

0x6a 106 j 'j'

0x6b 107 k 'k'

0x6c 108 l 'l'

0x6d 109 m 'm'

0x6e 110 n 'n'

0x6f 111 o 'o'

0x70 112 p 'p'

0x71 113 q 'q'

0x72 114 r 'r'

0x73 115 s 's'

0x74 116 t 't'

0x75 117 u 'u'

0x76 118 v 'v'

0x77 119 w 'w'

0x78 120 x 'x'

0x79 121 y 'y'

0x7a 122 z 'z'

0x7b 123 { '{'

0x7c 124 | '|'

0x7d 125 } '}'

0x7e 126 ~ '~'

0x7f 127 '\x7f'生成代码

#!/bin/env python

# coding=gbk

special = {

'\n' : r'\n (换行符)',

'\r' : r'\r (回车符)',

'\t' : r'\t (制表符)',

'\b' : r'\b (退格符)',

' ' : r'space(空格)',

'\0' : r'\0 (终止符)',

}

# line_format = '%-24s%-24s%-24s%s\n'

line_format = '%-24s%-24s%-24s%s'

def char2str(c):

n = ord(c)

if special.has_key(c):

return special[c]

if n <= 136 and n >= 33:

return c

return '\\x%x' % n

def cstyle(c):

if (c == '\0'):

return '\'\\0\''

ret = repr(c)

return ret.replace('\\x0', '\\x')

# f = open('ascii-table2.txt', 'w+')

# f.write(line_format % ('hex', 'dec', 'character', 'cstyle'))

print line_format % ('hex', 'dec', 'character', 'cstyle')

for i in range(0, 128):

line = line_format % ('0x%02x' % i, str(i), char2str(chr(i)), cstyle(chr(i)))

# f.write(line)

print line

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值