查询一段文字 ,找出最长的单词
import re
with open("xx.txt","r",encoding="utf-8") as f:
txt =f.read()
print(txt)
c =re.split("\W",txt)
print(c)
longest =""
for i in c:
if len(i) >len(longest):
longest =i
print(111,longest)
import re
with open("xx.txt","r",encoding="utf-8") as f:
txt =f.read()
print(txt)
c =re.split("\W",txt)
print(c)
longest =""
for i in c:
if len(i) >len(longest):
longest =i
print(111,longest)