摘要: 如果网页有连续性比如:baidu.com/1.html......baidu.com/10001.html那么就可以使用本python文件进行采集。 import requests from bs4 import BeautifulSoup s=1#网页开始的参数e=10001#网页结束的参数 fo 阅读全文
posted @ 2023-03-14 09:39 无恙大势 阅读(22) 评论(0) 推荐(0) 编辑
摘要: 在Python中,可以使用def关键字定义函数,并使用函数名和括号来调用它。函数的基本语法如下: def function_name(parameters): """函数文档字符串""" # 函数体 return result 其中,function_name是函数的名称,parameters是函数 阅读全文
posted @ 2023-03-14 08:53 无恙大势 阅读(419) 评论(0) 推荐(0) 编辑
摘要: import os from docx import Document # 创建新的空文档 merged_doc = Document() # 循环遍历所有.docx文件并将其合并到新文档中 for filename in os.listdir('.'): if filename.endswith( 阅读全文
posted @ 2023-03-12 14:48 无恙大势 阅读(182) 评论(0) 推荐(0) 编辑
摘要: from PIL import Image import os # 设置图片路径和分辨率 input_path = "input_folder" output_path = "output_folder" resolution = (1280, 720) # 循环处理图片 for filename 阅读全文
posted @ 2023-03-12 14:47 无恙大势 阅读(194) 评论(0) 推荐(0) 编辑
摘要: 以下是一个简单的科学计算器的Python代码示例,它支持基本的算术运算、三角函数、指数和对数运算等: import math def calculator(): print("欢迎使用科学计算器!") while True: try: expr = input("请输入一个表达式(输入 quit 退 阅读全文
posted @ 2023-03-12 14:37 无恙大势 阅读(251) 评论(0) 推荐(0) 编辑
摘要: #!/usr/bin/env python # -*- encoding: utf-8 -*- # here put the import lib import os import subprocess import random import string def rename_mp4_files 阅读全文
posted @ 2023-02-06 10:44 无恙大势 阅读(1190) 评论(0) 推荐(0) 编辑
摘要: pip install python-docx #第一步先安装python-docx模块 import docx def replace_text_in_word_document(file_path, old_text, new_text): doc = docx.Document(file_pa 阅读全文
posted @ 2023-02-04 11:04 无恙大势 阅读(755) 评论(0) 推荐(0) 编辑
摘要: <a href="https://www.example.com"> <img src="image.jpg" style="width:100%; height:auto;"> </a> 阅读全文
posted @ 2023-02-02 14:22 无恙大势 阅读(17) 评论(0) 推荐(0) 编辑
摘要: import json def txt_to_json(file_path): with open(file_path, "r") as file: lines = file.readlines() data = {} for line in lines: key, value = line.str 阅读全文
posted @ 2023-02-02 00:38 无恙大势 阅读(1183) 评论(0) 推荐(0) 编辑
摘要: 需要使用python-docx模块 pip install python-docx 然后函数主体 import os import docx2pdf def word_to_pdf(file_path): pdf_file = file_path.replace(".docx", ".pdf") d 阅读全文
posted @ 2023-02-02 00:03 无恙大势 阅读(1377) 评论(0) 推荐(0) 编辑
点击右上角即可分享
微信分享提示