python 打印可见字符
程序员文章站
2022-07-07 15:05:34
...
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
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
上一篇: beego日志 go