
Python
itze
这个作者很懒,什么都没留下…
展开
-
Python读取两个txt文件内容,重新写到新的txt文件
def test(): new_text_path="你需要写入文件的路径" oldText = open("你需要读取文件的路径1","r") newText = open("你需要读取文件的路径2","r") new_file_path=open("你需要写入文件的路径","w") for oldline in oldText: ne...原创 2019-03-15 15:56:14 · 6907 阅读 · 0 评论 -
Python去除txt文件重复行数,写到新的txt文件
rtext=open("你需要读取的文件路径","r") wtext=open("你需要写入的文件路径","w") lines=set() #声明空set for s in rtext: a = s.strip("\n") #去除换行键 b=a[-6:] if b not in lines: lines.add(b) if b==...原创 2019-03-15 16:04:54 · 905 阅读 · 1 评论 -
Python爬虫:爬取网页图片
目标网页路径:https://findicons.com/search/nature 先分析查找要爬取图片的路径 在浏览器F12 审查元素 整体实现代码 # -- coding:UTF-8 -- import requests from bs4 import BeautifulSoup import os ''' 思路:获取网址 获取图片地址 爬取图片...原创 2019-05-15 16:42:25 · 17931 阅读 · 6 评论