浅见池也 发表于 2017-4-30 15:04:19

python 打印可见字符

f = open(u'e:\\桌面\\a.txt')
Fchar = f.read()
f.close()
k = ""
for j in Fchar:
#    j = j.decode('gbk')
#    print len(j)
#    j = j.encode('gbk')
#    print len(j)
#    for i in j:
#      if ord(i) <= 128:
#            k += i
    if ord(j) <= 128 and ord(j) >= 32:
      k += j
    elif ord(j) == 9 or ord(j) == 10 or ord(j) == 13:
      k += j
if k == "":
    pass
else:
    print k
页: [1]
查看完整版本: python 打印可见字符