test_txt="""
http://baidu.com/123
http://baidu.com/article/1024.html
"""
while True:
fileName = input("请输入你要打开的文件\n>>>")
if not fileName:break
if not len(fileName) == 8:
print("\n****输入错误****")
print("****请重新输入****\n")
continue
file = open(fileName)
while True:
url = file.readline().strip('\n')
if not url:
break
host=url[:url.rindex("/")+1]
article=url[url.rindex("/")+1:]
print(host + "\n" + article)
使用Python读取TXT并且分割网址
最新推荐文章于 2024-05-10 14:31:12 发布