ValueError: chr() arg not in range(256)

使用chr(12288)填充中文空格,出现如下错误:python

ValueError: chr() arg not in range(256)编码

此错误是python2和python3的区别引发的。spa

在python2中chr( n) 将编码n 转为字符,n的范围是 0 ~ 255 
而python 3.0中,chr(n) 将编码n 转为字符,n的范围是 0 ~ 65535 
chr(12288)在3中表示中文空格,所以在python2中使用chr(12288)就会报错。code

在python2中能够用unichr(12288) 代替python2中的chr(12288)效果是同样的co