汉泰克1025G信号发生器二次开发(python和C)

2024-01-08 18:44

本文主要是介绍汉泰克1025G信号发生器二次开发(python和C),希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

信号发生器:汉泰克1025G
SDK开发资料:http://www.hantek.com.cn/products/detail/48

1.python接口

网上已经有大神制作了python的封装接口:https://github.com/AIMAtlanta/Hantek_1025G
这里为了方便查找就再张贴一遍:

# -*- coding: utf-8 -*-
"""
origin source: https://github.com/AIMAtlanta/Hantek_1025GPython wrapper providing access to C-language API provided by HTDDSDll.h.
Example usage:
ht = HantekDDS()
ht.drive_periodic(amplitude=2.0, frequency=12000., function = 'sine')
"""import ctypes
import os
import numpy as np
import threading
import time
import matplotlib.pyplot as plt
this_dir = os.path.dirname(os.path.realpath(__file__))
HTDLL = ctypes.windll.LoadLibrary(this_dir + '/HTDDSDll')FMAX = 200e6  # Maximum DAC sample rateclass HantekDDS():""" Interface to Hantek 1025G function generator."""def __init__(self, dev=0):""" Default constructor."""self.idVendor = '0x0483'self.idProduct = '0x5726'self.revNumber = '0200'self.dev_id = Noneself.connect(dev)self.param_dict = {'square_duty': 0.5,'triangle_duty': 0.5,'trap_rise': 0.2,'trap_high': 0.3,'trap_fall': 0.2,'exp_mode': 'decay','exp_time': 0.001,}self.halt = Falsedef connect(self, dev=0):""" Verify existence of device and get device id."""for attempt in range(10):n_devices = search()if n_devices:if bool(check(dev)):self.dev_id = devprint('Connected as device {:d}'.format(dev))returnprint('ERROR: Failed to establish connection with HantekDDS.')def set_divisor(self, div):""" Set the DAC sample rate divisor."""setDivNum(self.dev_id, div)def set_waveform(self, data):""" Set the waveform buffer."""data = np.array(data)  # Ensure data is in ndarraydlen = len(data)if dlen > 4096:print('WARNING: Hantek 1025G buffer limited to 4096 samples -- ' +'Truncating data to 4096 elements')data = data[:4096]if download(self.dev_id, data.tobytes(), dlen):passelse:print('HantekDDS method set_waveform() returned failure code.')def drive_periodic(self, amplitude=1.0, frequency=1000.0,offset=0, phase=0, function='sine', **kwargs):""" Direct the device to drive a periodic function.Args:amplitude: Amplitude of signal in Volts (1/2 V_pp)frequency: Frequency of signal in Hertzoffset: Offset of signal in Volts.phase: Offset of phase in periods (phase = 0 is equivalent tophase=1, phase = 0.5 is 180 degrees out of phase from phase = 0.function: Type of periodic function to drive.Valid Types-----------'sine': Sine wave'square': Square wave, param 'square_duty' for high duty cyclespecified as float in range (0,1)'triangle': Triangle wave, param 'duty' for rise duty cyclespecified as float in range (0,1)'ramp': Synonym for 'triangle''sawtooth': Synonym for 'triangle''trap': Trapezoidal wave, params 'trap_rise', 'trap_high',and 'trap_fall' for duty cycle for rise, high, and fallsegments specified as floats > 0 with sum <= 1.'exp': Exponential wave, params 'exp_mode' (may be 'rise' or'saturate') and 'exp_time' (time constant in seconds)."""for key,val in kwargs.items():if key in self.param_dict:self.param_dict[key] = valfrequency = validate_frequency(frequency)phase = phase % 1if (amplitude + abs(offset)) > 3.5:print('WARNING: amplitude and offset specified will cause ' +'the signal to be clipped.  Consider confining the range ' +'to ±3.5 volts.')if function not in periodic_functions.keys():print('WARNING: function type for periodic function not found. ' +'Valid values are ' +'Defaulting to sine wave.')function = 'sine'div, length = get_freq_settings(frequency)print(f'freq:{frequency}, div:{div}, length:{length}')f = periodic_functions[function]signal = f(amplitude, frequency, offset, phase,length, **(self.param_dict))digital = np.short(voltage_adc(signal))print(digital)self.set_waveform(digital)self.set_divisor(div)def frequency_scan(self, f_start, f_end, nsteps=10, delta=0, dwell=5,ltype='linear', n_repeats=1, amplitude=1.0, offset=0.0):""" Scan through a range of frequencies.Args:f_start: Scan starting frequency in Hertzf_end: Scan ending frequency in Hertznsteps: The number of steps to take between f_start and f_end.delta: The arithmetic or geometric difference between steps.If non-zero, this setting will override nsteps.Additionally, the frequency sweep may go past f_end.n_repeats: The number of times to loop through the entire frequencyscan.  Set to -1 to make continuous."""f_start = validate_frequency(f_start)f_end = validate_frequency(f_end)if ltype in ['log', 'logarithmic']:if delta > 0:nsteps = np.ceil(np.log(f_end / f_start) / np.log(delta))fspace = np.product(np.append(f_start, delta*np.ones(nsteps)))else:fspace = np.logspace(np.log10(f_start),np.log10(f_end), nsteps)if ltype in ['lin', 'linear']:if delta != 0:fspace = np.arange(f_start, f_end + delta, delta)else:fspace = np.linspace(f_start, f_end, nsteps)fspace = np.linspace(f_start, f_end, nsteps)self.scanner = threading.Thread(target=self.freq_scan_threaded,args=(fspace, amplitude,offset, dwell, n_repeats))self.halt = Falseself.scanner.start()
#        self.freq_scan_threaded(fspace, amplitude, offset, dwell, n_repeats)def freq_scan_threaded(self, fspace, amp, offset, dwell, n_repeats):""" Frequency scan to be started in non-blocking threaded process."""queue = int(n_repeats)while queue != 0:queue -= 1for f in fspace:if self.halt:return Noneself.drive_periodic(amplitude=amp, frequency=f, offset=offset)time.sleep(dwell)def stop(self):""" Halt the threaded scan process."""self.halt = Truedef search():""" Search for connected Hantek DDS devices.Will not return identity of devices, only the number connected."""fh = HTDLL[7]  # function handle for DDSSearch()return fh()def setFrequency(dev, f, npoints, nperiods):""" Set parameters appropriate for a particular frequency.Args:f: frequency to be set"""fh = HTDLL[11]return fh(dev, f, npoints, nperiods)def getMeasure():""" Retrieve the value from the frequency/counter function."""raise NotImplementedErrordef setSingleWave(dev, state):""" Set device to output continuously, or to output only on trigger."""fh = HTDLL[13]fh(dev, state)def resetCounter():""" Reset the count of the counter function."""fh = HTDLL[6]return fh(dev)def setTrigger(dev, internal, falling):""" Set trigger parameters."""fh = HTDLL[14]return fh(dev, internal, falling)def setDigitalIn():""" Read input values (low or high) from digital input ports.Lowest four bits of the read array are read from the 4 input pins."""raise NotImplementedErrordef setDIOMode():""" Switch between programmable output and generator output."""raise NotImplementedErrordef setDigitalOut():""" Set the output values (low or high) of the digital output ports.Lowest twelve bits of the output array are set on the 12 output pins."""raise NotImplementedErrordef download(dev, buf, num):""" Transfer a waveform specification to the device waveform buffer.Args:dev: Device indexbuf: Pointer to short type array (only 12 bits used)num: Number of elements in bufferReturns:bool: 1 on success, 0 on failure"""fh = HTDLL[2]return fh(dev, buf, num)def check(dev):""" Check the status of the device.Determine whether or not the device can be seen by the operating systemArgs:dev: Index of Hantek device.Returns:bool: status of connection (True = success, False = failure)Argument ``dev`` seems to be an internal index, presumably out of thenumber of Hantek devices connected.  If only one Hantek device isconnected, ``dev`` should probably always be 0."""fh = HTDLL[1]return fh(dev)def setPowerOnOutput(dev, state):""" Set whether waveform should output upon device power-onIf true, output stored function.  Otherwise, wait for a trigger (?) orexplicit command to output."""fh = HTDLL[12]return fh(dev, state)def getDivNum(dev):""" Get the DAC frequency divisorArgs:dev: device indexReturns:int: Divisor index number"""fh = HTDLL[4]return fh(dev)def setDivNum(dev, div):""" Set the DAC sampling rate divisor.Args:div: divisor to apply to DAC sampling frequency.Values of div from 1:n give sampling rates of fmax / (2 * div).When div == 0, sampling rate is ``FMAX`` = 200MS/sec."""fh = HTDLL[10]return fh(dev, div)def validate_frequency(frequency):if frequency > 1e8:print('WARNING: frequency {:g} is outside the '.format(frequency) +'possible range of frequencies for the Hantek 1025G.  ' +'Setting frequency to 10MHz for your "convenience".')frequency = 1e7if frequency < 1:print('WARNING: frequency {:g} is outside the '.format(frequency) +'possible range of frequencies for the Hantek 1025G.  ' +'Setting frequency to 10Hz for your "convenience".')frequency = 10return frequencydef get_freq_settings(frequency):""" Compute the DAC divisor and sample length for a a target frequency.Args:frequency: Target frequency in Hertz.Returns:int: divisor to be passed to setDivNumint: length to be passed to signal synthesis routinesThis function returns the same information that setFrequency does, butwithout modifying the DAC divisor."""frequency = validate_frequency(frequency)divisor = int(FMAX/4096/frequency)length = int(FMAX / max(1, 2 * divisor) / frequency)return divisor, lengthdef voltage_adc(voltage):""" Convert voltage in the range from -3.5V to +3.5V to a 12-bit level."""return np.minimum(4095, np.maximum(0, (3.5 - voltage) / 1.70898375e-3))# Periodic Functions
# ==================def sine_wave(amplitude, frequency, offset, phase, length, **kwargs):""" Construct one period of a sine wave."""arg = np.linspace(0, 2*np.pi, length, endpoint=False)signal = amplitude * np.sin(arg) + offsetreturn np.roll(signal, int(phase * length))def square_wave(amplitude, frequency, offset, phase, length, **kwargs):""" Construct one period of a square wave."""duty = kwargs['square_duty']cutoff = int(duty * length)signal = np.empty(length)signal[:cutoff] = amplitude + offsetsignal[cutoff:] = -amplitude + offsetreturn np.roll(signal, int(phase * length))def triangle_wave(amplitude, frequency, offset, phase, length, **kwargs):""" Construct one period of a triangle (sawtooth, ramp) wave."""duty = kwargs['triangle_duty']signal = np.empty(length)cutoff = int(duty * length)signal[:cutoff] = np.linspace(-amplitude, amplitude,cutoff, endpoint=False)signal[cutoff:] = np.linspace(amplitude, -amplitude,length - cutoff, endpoint=False)signal += offsetreturn np.roll(signal, int(phase * length))def exponential(amplitude, frequency, offset, phase, length, **kwargs):""" Construct an exponentially decaying/saturating wave."""tau = kwargs['exp_time']exp_mode = kwargs['exp_mode']time = np.linspace(0, 1/frequency, length, endpoint=False)if exp_mode == 'saturate':signal = amplitude * (1 - np.exp(-time / tau) + offset)if exp_mode == 'decay':signal = amplitude * (np.exp(-time / tau) + offset)return np.roll(signal, int(phase * length))def trapezoid(amplitude, frequency, offset, phase, length, **kwargs):""" Construct a trapezoidal wave."""d_rise = kwargs['trap_rise']d_high = kwargs['trap_high']d_fall = kwargs['trap_fall']if d_high + d_rise + d_fall > 1:print('Duty cycle greater than 1 specified for trapezoidal wave. ' +'Reseting to reasonable parameters.')d_rise = 0.2d_high = 0.3d_fall = 0.2l_r = c_r = int(d_rise * length)l_h = int(d_high * length)c_h = c_r + l_hl_f = int(d_fall * length)c_f = c_h + l_fsignal = np.empty(length)signal[:c_r] = np.linspace(-amplitude, amplitude, l_r, endpoint=False)signal[c_r:c_h] = amplitudesignal[c_h:c_f] = np.linspace(amplitude, -amplitude, l_f, endpoint=False)signal[c_f:] = -amplitudereturn np.roll(signal, int(phase * length))def arbitrary(amplitude, frequency, offset, phase, length, **kwargs):""" 创建任意波波形."""# 数据范围num = 10000M = 1e6n = 1e-9t = np.arange(0, 1000*n, (1000/num)*n)  # Only need to modify the parameters on lines 15-22# t = np.arange(0, 1000*n, 0.005*n)j = 1jts = 50*n  # Duration 50f0 = 30*M  # Frequency center 450fb = 100*M  # Bandwidth 100a = 1/(2*ts**2)b = np.sqrt((2*(np.pi**2)*(a**2))/((ts**2)*a)-2*(np.pi**2))A = (a/np.pi)**(1/4)  # Amplitudet0 = 500*n  # Time centerw0 = 2*np.pi*f0  # Frequency center# Incident wave functions = A*np.exp((-0.5*a*((t-t0)**2))+(j*0.5*b*((t-t0)**2))+j*w0*(t-t0))s = np.real(s)s_max = np.max(s)# 注意这里要进行转换s = np.floor((2**11-1)*(s/s_max))shift = len(s)//length # 原始数据长度5500signal = amplitude*(s/2048.0)[::shift]print('任意波数据长度:', len(signal))signal += offsetplt.plot(signal)plt.show()return np.roll(signal, int(phase * length))# Dictionary of all periodic functions
periodic_functions = {'sine': sine_wave,'square': square_wave,'triangle': triangle_wave,'sawtooth': triangle_wave,'ramp': triangle_wave,'trap': trapezoid,'exp': exponential,'arb': arbitrary}if __name__ == '__main__':# signal = arbitrary(amplitude=1, frequency=1000000, offset=0, phase=1, length=200,)ht = HantekDDS()# 任意波ht.drive_periodic(amplitude=3.5, frequency=2500000., function = 'arb')

上面python接口一个精妙的写法是使用索引的方式获取了函数句柄,例如DDSCheck函数为fh = HTDLL[1],但是问题来了,原作者是如何知道不同函数对应的索引值?经过一番查找,笔者发现可以使用DDL函数查看器(自行搜索下载)实现查找,如下图所示:
在这里插入图片描述
由于官方提供的.dll和.lib文件都是32位的,因此上述程序需要在32位python环境运行

2.C接口

官方提供了VC例程,但是项目太老不容易用新版的VS打开,而且很多时候只需要简单的几个指令即可,下面贴出1025G下载任意波形的代码,注意波形点数和频率有关:

1025G最大采样率为200MS/s(200e6),如果任意波波形频率为100M,即一个周期1us,1us时间在200MS/s采样率下可以采集200个点,因此100M频率任意波形的数据缓冲大小为200,其它以此类推,计算公式如下,其中freq为需要下载波形的频率,FMAX为信号发生器采样频率,这里默认为200MS/s,也可以设置分频系数进行调整
点数 = 1 f r e q 1 F M A X 点数=\frac{\frac{1}{freq}}{\frac{1}{FMAX}} 点数=FMAX1freq1

#include <iostream>
#include <windows.h>
#include <stdio.h>
#include <cmath>
#include <cstdint>
#include "HTDDSDll.h"#pragma comment(lib, "HTDDSDll.lib") // 使用库#define BUF_SIZE 4096
#define MAX_VOLT 3.5f
typedef unsigned short USHORT;int main(int argc, char *argv[])
{int device_index = 0;double frequency = 1e6;int wave_point_num = 200; // 1M->200,2M->100,int wave_period_num = 1;bool downStatus = false; // 波形下载状态BOOL device_available;// BOOL result_set_frequency;// 搜索设备printf(">>> Searching DDS devices...\n");int result_search = DDSSearch();if (result_search > 0){printf("Found %d devices!\n", result_search);}else{printf("!!! Device not found@\n");return -1;}// 检查设备是否可用printf(">>> Checking DDS devices...\n");device_available = DDSCheck(device_index);if (device_available){printf("Device available!\n");}else{printf("!!! Device not available!\n");return -1;}// 设置频率// result_set_frequency = DDSSetFrequency(device_index, frequency, &wave_point_num, &wave_period_num);// if (result_set_frequency) {//     printf("Frequency set successfully!\n");// } else {//     printf("频率设置失败\n");//     return -1;// }// 创建波形USHORT buffer1M[BUF_SIZE] = {2048, 2049, 2049, 2048, 2049, 2049, 2048, 2049, 2049, 2048, 2048, 2049, 2048, 2048,2049, 2049, 2048, 2048, 2049, 2049, 2048, 2048, 2049, 2049, 2048, 2048, 2049, 2049,2048, 2048, 2048, 2049, 2049, 2048, 2048, 2048, 2049, 2049, 2049, 2048, 2048, 2048,2049, 2049, 2049, 2049, 2048, 2047, 2046, 2047, 2048, 2051, 2054, 2057, 2056, 2053,2047, 2039, 2029, 2020, 2011, 2005, 2002, 2002, 2006, 2012, 2020, 2030, 2039, 2046,2048, 2045, 2030, 2002, 1955, 1884, 1789, 1669, 1533, 1399, 1295, 1263, 1347, 1583,1981, 2495, 3015, 3370, 3376, 2918, 2048, 1045, 359, 422, 1360, 2784, 3877, 3846,2553, 823, 1, 874, 2795, 4020, 3302, 1313, 181, 1201, 3160, 3630, 2048, 603,1283, 2982, 3107, 1602, 1003, 2189, 2957, 2035, 1295, 2059, 2658, 1972, 1579, 2213,2367, 1818, 1894, 2287, 2048, 1873, 2149, 2111, 1935, 2085, 2100, 1983, 2069, 2075,2011, 2067, 2055, 2030, 2064, 2044, 2045, 2056, 2042, 2052, 2048, 2047, 2051, 2047,2050, 2048, 2048, 2049, 2048, 2049, 2048, 2049, 2048, 2049, 2048, 2049, 2048, 2049,2048, 2049, 2048, 2049, 2048, 2049, 2048, 2049, 2048, 2049, 2048, 2049, 2048, 2049,2048, 2049, 2048, 2048, 2049, 2048, 2049, 2048, 2048, 2049, 2048, 2049, 2048, 2048,2049, 2048, 2049, 2049};USHORT buffer2M[BUF_SIZE] = {2048, 2048, 2049, 2049, 2048, 2049, 2048, 2048, 2049, 2048, 2049, 2048, 2049, 2048, 2049,2048, 2048, 2049, 2048, 2049, 2049, 2048, 2049, 2049, 2048, 2046, 2048, 2054, 2056,2047, 2029, 2011, 2002, 2006, 2020, 2039, 2048, 2030, 1955, 1789, 1533, 1295, 1347,1981, 3015, 3376, 2048, 359, 1360, 3877, 2553, 1, 2795, 3302, 181, 3160, 2048,830, 3107, 1003, 2957, 1295, 2658, 1579, 2367, 1894, 2048, 2149, 1935, 2100, 2069,2011, 2055, 2064, 2045, 2042, 2048, 2051, 2050, 2048, 2048, 2048, 2048, 2048, 2048,2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2049, 2049, 2048, 2048, 2048,2049, 2049};USHORT buffer500k[BUF_SIZE] = {2048, 2048, 2049, 2049, 2049, 2048, 2048, 2048, 2048, 2049, 2049, 2049, 2048, 2048, 2048, 2049, 2049, 2049, 2048, 2048, 2048,2049, 2049, 2049, 2048, 2048, 2048, 2048, 2049, 2049, 2049, 2048, 2048, 2048, 2049,2049, 2049, 2049, 2048, 2048, 2048, 2048, 2049, 2049, 2049, 2049, 2048, 2048, 2048,2048, 2049, 2049, 2049, 2049, 2048, 2048, 2048, 2048, 2049, 2049, 2049, 2049, 2049,2048, 2048, 2048, 2048, 2048, 2049, 2049, 2049, 2049, 2049, 2048, 2048, 2048, 2048,2048, 2049, 2049, 2049, 2049, 2049, 2049, 2048, 2048, 2048, 2048, 2048, 2048, 2048,2049, 2049, 2049, 2049, 2049, 2049, 2049, 2049, 2048, 2047, 2047, 2046, 2046, 2046,2047, 2047, 2048, 2050, 2051, 2053, 2054, 2056, 2057, 2057, 2056, 2055, 2053, 2051,2047, 2044, 2039, 2034, 2029, 2024, 2020, 2015, 2011, 2008, 2005, 2003, 2002, 2001,2002, 2003, 2006, 2008, 2012, 2016, 2020, 2025, 2030, 2034, 2039, 2042, 2046, 2048,2048, 2048, 2045, 2039, 2030, 2018, 2002, 1981, 1955, 1923, 1884, 1840, 1789, 1731,1669, 1602, 1533, 1464, 1399, 1341, 1295, 1268, 1263, 1288, 1347, 1445, 1583, 1763,1981, 2228, 2495, 2764, 3015, 3225, 3370, 3427, 3376, 3207, 2918, 2523, 2048, 1538,1045, 631, 359, 279, 422, 793, 1360, 2056, 2784, 3430, 3877, 4033, 3846, 3327,2553, 1659, 823, 222, 1, 229, 874, 1801, 2795, 3606, 4020, 3914, 3302, 2345,1313, 509, 181, 438, 1201, 2223, 3160, 3691, 3630, 3003, 2048, 1130, 603, 667,2035, 1487, 1295, 1544, 2059, 2520, 2658, 2415, 1972, 1622, 1579, 1843, 2213, 2432,2367, 2091, 1818, 1741, 1894, 2141, 2287, 2236, 2048, 1886, 1873, 2001, 2149, 2194,2111, 1988, 1935, 1987, 2085, 2135, 2100, 2023, 1983, 2010, 2069, 2098, 2075, 2030,2011, 2033, 2067, 2076, 2055, 2031, 2030, 2049, 2064, 2059, 2044, 2037, 2045, 2055,2056, 2048, 2042, 2045, 2052, 2053, 2048, 2045, 2047, 2050, 2051, 2048, 2047, 2048,2050, 2049, 2048, 2048, 2048, 2049, 2049, 2048, 2048, 2049, 2049, 2048, 2048, 2048,2049, 2049, 2048, 2048, 2049, 2049, 2048, 2048, 2049, 2049, 2048, 2048, 2049, 2049,2048, 2048, 2049, 2049, 2048, 2048, 2049, 2049, 2048, 2048, 2049, 2049, 2048, 2048,2049, 2049, 2048, 2048, 2049, 2049, 2048, 2048, 2049, 2049, 2048, 2049, 2049, 2048,2048, 2049, 2049, 2048, 2048, 2049, 2048, 2048, 2049, 2049, 2048, 2049, 2049, 2048,2048, 2049, 2048, 2048, 2049, 2049, 2048, 2049, 2049, 2048, 2048, 2049, 2048, 2048,2049, 2048, 2048, 2049, 2049, 2048, 2049, 2049, 2048, 2048, 2049, 2049, 2049, 2048, 2048,};// 下载波形// 根据传入的参数选择数组std::string param;if (argc > 1) // 输入参数,控制下载波形{param = argv[1];// 显示帮助信息if (param == "-h"){std::cout << "Help information:\n";std::cout << "Usage: \n";std::cout << "  main.exe [frequency]\n";std::cout << "Where [frequency] can be:\n";std::cout << "  1M   - Generate 1MHz waveform\n";std::cout << "  2M   - Generate 2MHz waveform\n";std::cout << "  500k - Generate 500kHz waveform\n";std::cout << "If no argument provided, just check device status.\n";}else{if (param == "1M"){wave_point_num = 200;downStatus = DDSDownload(device_index, buffer1M, wave_point_num);printf(">>> Writing 1M-freq wave...\n");}else if (param == "2M"){wave_point_num = 100;downStatus = DDSDownload(device_index, buffer2M, wave_point_num);printf(">>> Writing 2M-freq wave...\n");}else if (param == "500k"){wave_point_num = 400;downStatus = DDSDownload(device_index, buffer500k, wave_point_num);printf(">>> Writing 500k-freq wave...\n");}else{ // 默认情况为检查设备状态printf("!!! Wrong arguments, please check !\n");}if (downStatus){printf("Writing wave successfully!\n");}else{printf("Failed to write wave!\n");return -1;}}}return 0;
}

这篇关于汉泰克1025G信号发生器二次开发(python和C)的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/584436

相关文章

Python调用Orator ORM进行数据库操作

《Python调用OratorORM进行数据库操作》OratorORM是一个功能丰富且灵活的PythonORM库,旨在简化数据库操作,它支持多种数据库并提供了简洁且直观的API,下面我们就... 目录Orator ORM 主要特点安装使用示例总结Orator ORM 是一个功能丰富且灵活的 python O

Python使用国内镜像加速pip安装的方法讲解

《Python使用国内镜像加速pip安装的方法讲解》在Python开发中,pip是一个非常重要的工具,用于安装和管理Python的第三方库,然而,在国内使用pip安装依赖时,往往会因为网络问题而导致速... 目录一、pip 工具简介1. 什么是 pip?2. 什么是 -i 参数?二、国内镜像源的选择三、如何

python使用fastapi实现多语言国际化的操作指南

《python使用fastapi实现多语言国际化的操作指南》本文介绍了使用Python和FastAPI实现多语言国际化的操作指南,包括多语言架构技术栈、翻译管理、前端本地化、语言切换机制以及常见陷阱和... 目录多语言国际化实现指南项目多语言架构技术栈目录结构翻译工作流1. 翻译数据存储2. 翻译生成脚本

如何通过Python实现一个消息队列

《如何通过Python实现一个消息队列》这篇文章主要为大家详细介绍了如何通过Python实现一个简单的消息队列,文中的示例代码讲解详细,感兴趣的小伙伴可以跟随小编一起学习一下... 目录如何通过 python 实现消息队列如何把 http 请求放在队列中执行1. 使用 queue.Queue 和 reque

Python如何实现PDF隐私信息检测

《Python如何实现PDF隐私信息检测》随着越来越多的个人信息以电子形式存储和传输,确保这些信息的安全至关重要,本文将介绍如何使用Python检测PDF文件中的隐私信息,需要的可以参考下... 目录项目背景技术栈代码解析功能说明运行结php果在当今,数据隐私保护变得尤为重要。随着越来越多的个人信息以电子形

使用Python快速实现链接转word文档

《使用Python快速实现链接转word文档》这篇文章主要为大家详细介绍了如何使用Python快速实现链接转word文档功能,文中的示例代码讲解详细,感兴趣的小伙伴可以跟随小编一起学习一下... 演示代码展示from newspaper import Articlefrom docx import

Python Jupyter Notebook导包报错问题及解决

《PythonJupyterNotebook导包报错问题及解决》在conda环境中安装包后,JupyterNotebook导入时出现ImportError,可能是由于包版本不对应或版本太高,解决方... 目录问题解决方法重新安装Jupyter NoteBook 更改Kernel总结问题在conda上安装了

如何通过海康威视设备网络SDK进行Java二次开发摄像头车牌识别详解

《如何通过海康威视设备网络SDK进行Java二次开发摄像头车牌识别详解》:本文主要介绍如何通过海康威视设备网络SDK进行Java二次开发摄像头车牌识别的相关资料,描述了如何使用海康威视设备网络SD... 目录前言开发流程问题和解决方案dll库加载不到的问题老旧版本sdk不兼容的问题关键实现流程总结前言作为

Python如何计算两个不同类型列表的相似度

《Python如何计算两个不同类型列表的相似度》在编程中,经常需要比较两个列表的相似度,尤其是当这两个列表包含不同类型的元素时,下面小编就来讲讲如何使用Python计算两个不同类型列表的相似度吧... 目录摘要引言数字类型相似度欧几里得距离曼哈顿距离字符串类型相似度Levenshtein距离Jaccard相

Python安装时常见报错以及解决方案

《Python安装时常见报错以及解决方案》:本文主要介绍在安装Python、配置环境变量、使用pip以及运行Python脚本时常见的错误及其解决方案,文中介绍的非常详细,需要的朋友可以参考下... 目录一、安装 python 时常见报错及解决方案(一)安装包下载失败(二)权限不足二、配置环境变量时常见报错及