type()
peicheng@PCsNB ~/project/python/chinese $ cat readr3.py
#coding=utf-8
f=open('rec2','r')
lines=f.readlines()
print type(lines)
for line in lines:
print line,
print type(line)
print line,
line=line.decode('utf-8').rstrip()
print len(line)
print type(line)
result
peicheng@PCsNB ~/project/python/chinese $ python readr3.py
<type 'list'>
test1
test2
<type 'str'>
test2
5
<type 'unicode'>
沒有留言:
張貼留言