for i in xrange(256):
print str(i)+' : '+chr(i)
當這個代碼運行some of characters not shown and instead them show squares爲什麼我的Python代碼不代表某些字符?
我一直在努力,但是當我運行這段代碼我不能修復該問題 連:
print "\a"
沒有任何反應 我沒有聽到鐘聲聲音
for i in xrange(256):
print str(i)+' : '+chr(i)
當這個代碼運行some of characters not shown and instead them show squares爲什麼我的Python代碼不代表某些字符?
我一直在努力,但是當我運行這段代碼我不能修復該問題 連:
print "\a"
沒有任何反應 我沒有聽到鐘聲聲音
以及你打印出來的ASCII字符。打印出的數字首先不是字母字符,比如here
您無法打印所有ASCII字符。在這裏您可以找到所有的ASCII字符。
print ' '.join([chr(i) for i in range(128)])
下面是這種
'\x00 \x01 \x02 \x03 \x04 \x05 \x06 \x07 \x08 \t \n \x0b \x0c \r \x0e \x0f \x10 \x11 \x12 \x13 \x14 \x15 \x16 \x17 \x18 \x19 \x1a \x1b \x1c \x1d \x1e \x1f ! " # $ % & \' () * + , - ./0 1 2 3 4 5 6 7 8 9 : ; <=> ? @ A B C D E F G H I J K L M N O P Q R S T U V W X Y Z [ \\ ]^_ ` a b c d e f g h i j k l m n o p q r s t u v w x y z { | } ~ \x7f'
的結果,在此可打印字符如下。哪個ca可以找到。
In [34]: import string
In [35]: print string.printable
結果
abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!"#$%&'()*+,-./:;<=>[email protected][\]^_`{|}~
你需要看一看ASCII表:http://www.asciitable.com – Keiwan
嘗試檢查,如果'CHR(I).isprintable()'因爲不是所有的字符都可打印/ –