python的txt文件存取

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接: https://blog.csdn.net/lipachong/article/details/99692281
#读文件
with open("xiaoqu_url.txt", "r+", encoding="utf-8") as f:
            content=f.read()
            url_list=content[:-1].split(',')#取出来的元素会根据逗号分割成一个列表形式
#写文件
with open("xiaoqu_url.txt", "a+", encoding="utf-8") as f:
               f.write(url + ",")

猜你喜欢

转载自blog.csdn.net/lipachong/article/details/99692281