习题P184
Python自带的open可以打开指定文字编码的文件。 只需要传入encoding函数即可 2.
length
= {}
with open('test.txt','r') as f
:
for i
in f
:
print(i
)
word
= i
.split
(' ')
del word
[len(word
)-1]
for i
in range(len(word
)):
length
[word
[i
]] = len(word
[i
])
rst
= max(length
, key
=length
.get
)
print(rst
)
这是文本内容: 程序运行结果:
转载请注明原文地址:https://blackberry.8miu.com/read-18456.html