随笔分类 -  Python

1 2 3 4 5 ··· 15 下一页
Python zone
摘要:import sys import cv2 import numpy as np import requests from io import BytesIO from PyQt5.QtWidgets import QApplication, QLabel, QVBoxLayout, QWidget 阅读全文
posted @ 2025-06-16 17:55 西北逍遥 阅读(3) 评论(0) 推荐(0)
摘要:import sys import cv2 import numpy as np from PyQt5.QtCore import QThread, pyqtSignal, Qt from PyQt5.QtGui import QImage, QPixmap from PyQt5.QtWidgets 阅读全文
posted @ 2025-06-12 22:46 西北逍遥 阅读(4) 评论(0) 推荐(0)
摘要:import os import csv def process_files(folder_path, output_csv): # 准备数据列表 data = [] serial=1 # 遍历文件夹中的所有文件 for filename in os.listdir(folder_path): pr 阅读全文
posted @ 2025-05-15 23:37 西北逍遥 阅读(11) 评论(0) 推荐(0)
摘要:def putText_Img(self,img1): # now1 = datetime.now() self.now_date_str = now1.strftime("%Y-%m-%d %H:%M:%S") print(self.now_date_str) #self.cameraImg = 阅读全文
posted @ 2025-04-01 02:24 西北逍遥 阅读(18) 评论(0) 推荐(0)
摘要:import socket try: # 你的socket代码,例如创建一个连接 s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect(('localhost', 8080)) except socket.timeout: p 阅读全文
posted @ 2025-03-03 15:56 西北逍遥 阅读(16) 评论(0) 推荐(0)
摘要:(base) bim@bim-Smart-Client:~/Anaconda$ (base) bim@bim-Smart-Client:~/Anaconda$ (base) bim@bim-Smart-Client:~/Anaconda$ conda create -n wind_2025 pyth 阅读全文
posted @ 2025-01-11 15:36 西北逍遥 阅读(31) 评论(0) 推荐(0)
摘要:import time import math import numpy as np # A small helper function to limit angles between -pi and pi def wrap_to_pi(angle): while angle > math.pi: 阅读全文
posted @ 2025-01-11 10:21 西北逍遥 阅读(16) 评论(0) 推荐(0)
摘要:VTK环境 (base) C:\Users\BIM> (base) C:\Users\BIM>conda create -n vtk_env python==3.8 Collecting package metadata (current_repodata.json): done Solving e 阅读全文
posted @ 2024-12-10 07:43 西北逍遥 阅读(32) 评论(0) 推荐(0)
摘要:# -*- coding: utf8 -*- import serial import time import datetime import struct # 替换成你的串口名称和波特率 ser = serial.Serial('COM5', 115200, timeout=1) def anal 阅读全文
posted @ 2024-09-13 15:30 西北逍遥 阅读(32) 评论(0) 推荐(0)
摘要:ImageDraw.Draw 填充区域 在Python的PIL(Python Imaging Library,现在通常称为Pillow)库中,ImageDraw.Draw 对象用于在图像上绘制形状。要填充一个区域,你通常会使用 rectangle、ellipse、polygon 等方法,并指定填充颜 阅读全文
posted @ 2024-08-30 19:12 西北逍遥 阅读(201) 评论(0) 推荐(0)
摘要:python 计算list的方差 import numpy as np # 假设我们有一个包含数值的列表 data = [1, 2, 3, 4, 5] # 计算均值 mean = np.mean(data) # 计算方差 variance = np.var(data) # 这将使用默认的N-1作为分 阅读全文
posted @ 2024-08-21 18:12 西北逍遥 阅读(237) 评论(0) 推荐(0)
摘要:python获取当前日期 年月日时分秒 from datetime import datetime now = datetime.now() current_time = now.strftime("%Y-%m-%d %H:%M:%S") ############################## 阅读全文
posted @ 2024-08-13 22:05 西北逍遥 阅读(265) 评论(0) 推荐(0)
摘要:pyqt5 combox选择事件绑定 import sys from PyQt5.QtWidgets import QApplication, QWidget, QComboBox, QVBoxLayout, QLabel class ComboBoxExample(QWidget): def __ 阅读全文
posted @ 2024-08-12 15:13 西北逍遥 阅读(194) 评论(0) 推荐(0)
摘要:python 读取文本文件 # 打开文件 with open('myfile.txt', 'r') as file: # 读取文件内容 content = file.read() # 打印文件内容 print(content) ########################## 阅读全文
posted @ 2024-08-10 19:38 西北逍遥 阅读(16) 评论(0) 推荐(0)
摘要:python 逐行读取文本文件 # 打开文件 with open('myfile.txt', 'r') as file: # 逐行读取文件内容 for line in file: print(line, end='') # 注意,print 函数默认会在每行末尾添加换行符,所以这里使用 end='' 阅读全文
posted @ 2024-08-07 20:22 西北逍遥 阅读(27) 评论(0) 推荐(0)
摘要:python 写入文本文件 # 打开文件,如果文件不存在则创建它 with open('myfile.txt', 'w') as file: # 写入内容 file.write('kkkkkkkkkkkkkkkkkkk!\n') ################################### 阅读全文
posted @ 2024-08-06 18:48 西北逍遥 阅读(23) 评论(0) 推荐(0)
摘要:python 追加到文本文件 # 打开文件以追加内容 with open('myfile.txt', 'a') as file: # 追加内容 file.write('kkkkkkkkkkkkkkkkkkkkk.\n') ################################# 阅读全文
posted @ 2024-08-03 19:35 西北逍遥 阅读(19) 评论(0) 推荐(0)
摘要:python 修改文本文件 # 读取文件内容 with open('myfile.txt', 'r') as file: content = file.read() # 修改内容(这里只是一个简单的替换示例) modified_content = content.replace('old_text' 阅读全文
posted @ 2024-07-30 18:53 西北逍遥 阅读(41) 评论(0) 推荐(0)
摘要:python 读取CSV文件 import csv # 打开CSV文件 with open('example.csv', 'r', newline='') as file: reader = csv.reader(file) # 遍历CSV文件的每一行 for row in reader: prin 阅读全文
posted @ 2024-07-29 16:52 西北逍遥 阅读(15) 评论(0) 推荐(0)
摘要:python 写入CSV文件 import csv # 定义要写入CSV文件的数据 data = [ ['Name', 'Age', 'City'], ['Alice', '25', 'New York'], ['Bob', '30', 'San Francisco'], # ... ] # 打开C 阅读全文
posted @ 2024-07-28 15:56 西北逍遥 阅读(25) 评论(0) 推荐(0)

1 2 3 4 5 ··· 15 下一页