随笔分类 -  Python

上一页 1 2 3 4 5 6 7 8 ··· 15 下一页
Python zone
摘要:拷贝整个目录及其子目录和文件,可以使用shutil.copytree()函数。 import shutil # 源目录路径 src_dir = '/path/to/source/directory' # 目标目录路径 dst_dir = '/path/to/destination/directory 阅读全文
posted @ 2023-09-30 17:51 西北逍遥 阅读(389) 评论(0) 推荐(0)
摘要:from datetime import datetime # 获取当前时间 now = datetime.now() # 获取年、月、日、时、分、秒和毫秒 year = now.year month = now.month day = now.day hour = now.hour minute 阅读全文
posted @ 2023-09-29 20:17 西北逍遥 阅读(1079) 评论(0) 推荐(0)
摘要:在Python中,可以使用os模块的rename()函数来重命名文件。以下是一个基本的示例: import os # 原文件的路径 old_file_path = '/path/to/your/old_file_name.txt' # 新文件的路径 new_file_path = '/path/to 阅读全文
posted @ 2023-09-28 21:13 西北逍遥 阅读(85) 评论(0) 推荐(0)
摘要:pip install pandas openpyxl 读取Excel文件 import pandas as pd # 读取Excel文件 df = pd.read_excel('your_file.xlsx') # 查看数据 print(df) 写入Excel文件 import pandas as 阅读全文
posted @ 2023-09-26 08:55 西北逍遥 阅读(37) 评论(0) 推荐(0)
摘要:from PyQt5.QtCore import QThread, pyqtSignal import time class MyThread(QThread): finished = pyqtSignal() def run(self): print('Thread started.') time 阅读全文
posted @ 2023-09-25 16:52 西北逍遥 阅读(21) 评论(0) 推荐(0)
摘要:python request请求数据 # -*- coding:utf-8 -*- import requests import json #查询塔吊X数据 def searchTowerXValue(): towerXValue = 0.0 try: # 从服务器请求数据 response = r 阅读全文
posted @ 2023-09-19 08:49 西北逍遥 阅读(35) 评论(0) 推荐(0)
摘要:在PyQt中,可以使用matplotlib库来绘制折线图。 import sys from PyQt5.QtWidgets import QApplication, QMainWindow, QVBoxLayout, QWidget from matplotlib.figure import Fig 阅读全文
posted @ 2023-09-16 17:59 西北逍遥 阅读(483) 评论(0) 推荐(0)
摘要:import numpy as np from scipy.signal import argrelextrema def emd(data): """ 经验模式分解(Empirical Mode Decomposition,EMD) """ # 找到极值点 max_points, min_poin 阅读全文
posted @ 2023-09-15 12:00 西北逍遥 阅读(609) 评论(0) 推荐(0)
摘要:test2 = [range(1, 101)] print(test2) my_list = list(range(1, 101)) print(my_list) my_list2 = list(range(100, 0,-1)) print(my_list2) my_list3 = [0] * 1 阅读全文
posted @ 2023-09-13 15:36 西北逍遥 阅读(224) 评论(0) 推荐(0)
摘要:opencv resize import cv2 from ccv import ccv2 # 读取图像 image = cv2.imread("example.jpg") # 调整图像大小 resized_image = ccv2.resize(image, 300, 300, ccv2.INTE 阅读全文
posted @ 2023-09-12 16:36 西北逍遥 阅读(36) 评论(0) 推荐(0)
摘要:当使用Python的requests.post函数时,可以在其中添加异常处理来捕获可能的网络错误或HTTP错误。以下是一个示例代码,演示如何使用try-except语句来处理requests.post可能抛出的异常: import requests url = 'http://cbim.com/up 阅读全文
posted @ 2023-09-11 17:08 西北逍遥 阅读(571) 评论(0) 推荐(0)
摘要:在PyQt中,可以使用matplotlib库来绘制折线图并设置y轴的最大最小值。 import sys from PyQt5.QtWidgets import QApplication, QMainWindow, QVBoxLayout, QWidget from matplotlib.figure 阅读全文
posted @ 2023-09-10 13:47 西北逍遥 阅读(200) 评论(0) 推荐(0)
摘要:1、 (base) C:\Users\Administrator> (base) C:\Users\Administrator> (base) C:\Users\Administrator>conda create -n wind_2023 python==3.7 Collecting packag 阅读全文
posted @ 2023-09-08 20:09 西北逍遥 阅读(203) 评论(0) 推荐(0)
摘要:import sys from PyQt5.QtWidgets import QApplication, QMainWindow, QVBoxLayout, QWidget from matplotlib.figure import Figure from matplotlib.backends.b 阅读全文
posted @ 2023-09-07 07:34 西北逍遥 阅读(304) 评论(0) 推荐(0)
摘要:使用 requests 库可以方便地上传多个文件和其他字段。当使用Python的requests.post函数时,您可以在其中添加异常处理来捕获可能的网络错误或HTTP错误。 import requests url = 'http://cbim.com/upload' files = {'file1 阅读全文
posted @ 2023-09-05 12:53 西北逍遥 阅读(382) 评论(0) 推荐(0)
摘要:python 计算两个日期之间的时间差,并将其转换为秒数 from datetime import datetime, timedelta # 创建两个日期对象 date1 = datetime(2023, 7, 2) date2 = datetime(2023, 7, 4) # 计算时间差,并转换 阅读全文
posted @ 2023-09-04 17:45 西北逍遥 阅读(791) 评论(0) 推荐(0)
摘要:python post上传文件 import requests import json url = 'http://cnbim.com/upload' file_path = 'path/1/2/file.jpg' data = { 'file': open(file_path, 'rb'), 'i 阅读全文
posted @ 2023-08-31 08:32 西北逍遥 阅读(141) 评论(0) 推荐(0)
摘要:python request session try: # verify参数来解决ssl报错问题 request_result = self.request_sess.post(url,data,verify=False) print(request_result) except Exception 阅读全文
posted @ 2023-08-28 18:57 西北逍遥 阅读(46) 评论(0) 推荐(0)
摘要:ptthon拼图 from PIL import Image # 打开图像文件 image = Image.open("input_image.jpg") # 获取图像的宽度和高度 width, height = image.size # 创建一个新的图像,将原始图像复制到其上 new_image 阅读全文
posted @ 2023-07-09 20:55 西北逍遥 阅读(71) 评论(0) 推荐(0)
摘要:import xml.etree.ElementTree as ET # 加载XML文档 tree = ET.parse('example.xml') # 获取根元素 root = tree.getroot() # 遍历XML文档中的元素 for child in root: print(child 阅读全文
posted @ 2023-06-16 21:16 西北逍遥 阅读(17) 评论(0) 推荐(0)

上一页 1 2 3 4 5 6 7 8 ··· 15 下一页