随笔分类 -  Python

1 2 3 4 5 ··· 15 下一页
Python zone
摘要:from PIL import Image import os images = [Image.open(f) for f in sorted(os.listdir('J:\\PytorchProject\\jpg3\\')) if f.endswith('.jpg')] images[0].sav 阅读全文
posted @ 2025-10-01 00:02 西北逍遥 阅读(9) 评论(0) 推荐(0)
摘要:import torch # 1. 检查 PyTorch 版本 print("PyTorch 版本:", torch.__version__) # 应为 2.4.0 # 2. 检查 CUDA 是否可用 print("CUDA 可用:", torch.cuda.is_available()) # 应为 阅读全文
posted @ 2025-09-21 15:51 西北逍遥 阅读(13) 评论(0) 推荐(0)
摘要:安装psutil: pip install psutil import psutil def get_disk_space(drive_letter='D:'): """ 获取指定磁盘分区的空间使用情况 参数: drive_letter (str): 磁盘驱动器号,默认为'D:' 返回: tuple 阅读全文
posted @ 2025-07-08 16:17 西北逍遥 阅读(41) 评论(0) 推荐(0)
摘要: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 西北逍遥 阅读(6) 评论(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 西北逍遥 阅读(12) 评论(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 西北逍遥 阅读(22) 评论(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 西北逍遥 阅读(32) 评论(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 西北逍遥 阅读(22) 评论(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 西北逍遥 阅读(66) 评论(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 西北逍遥 阅读(31) 评论(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 西北逍遥 阅读(58) 评论(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 西北逍遥 阅读(46) 评论(0) 推荐(0)
摘要:ImageDraw.Draw 填充区域 在Python的PIL(Python Imaging Library,现在通常称为Pillow)库中,ImageDraw.Draw 对象用于在图像上绘制形状。要填充一个区域,你通常会使用 rectangle、ellipse、polygon 等方法,并指定填充颜 阅读全文
posted @ 2024-08-30 19:12 西北逍遥 阅读(267) 评论(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 西北逍遥 阅读(257) 评论(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 西北逍遥 阅读(275) 评论(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 西北逍遥 阅读(230) 评论(0) 推荐(0)
摘要:python 读取文本文件 # 打开文件 with open('myfile.txt', 'r') as file: # 读取文件内容 content = file.read() # 打印文件内容 print(content) ########################## 阅读全文
posted @ 2024-08-10 19:38 西北逍遥 阅读(20) 评论(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 西北逍遥 阅读(33) 评论(0) 推荐(0)
摘要:python 写入文本文件 # 打开文件,如果文件不存在则创建它 with open('myfile.txt', 'w') as file: # 写入内容 file.write('kkkkkkkkkkkkkkkkkkk!\n') ################################### 阅读全文
posted @ 2024-08-06 18:48 西北逍遥 阅读(26) 评论(0) 推荐(0)
摘要:python 追加到文本文件 # 打开文件以追加内容 with open('myfile.txt', 'a') as file: # 追加内容 file.write('kkkkkkkkkkkkkkkkkkkkk.\n') ################################# 阅读全文
posted @ 2024-08-03 19:35 西北逍遥 阅读(23) 评论(0) 推荐(0)

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