第三十章 方法大全(Python)

在国产麒麟V10(arm64)上离线部署Docker 24.0.6和Compose 2.30.1,保姆级避坑实录 本文详细介绍了在国产麒麟V10(arm64)操作系统上离线部署Docker 24.0.6和Compose 2.30.1的完整流程,包括环境准备、架构认知、安装步骤、系统服务优化及生产环境加固。特别针对ARM64架构的兼容性问题提供了解决方案,帮助用户在信创环境中高效部署容器化技术。 阅读详情


一、日期

1、time模块

import time

1.1、time.sleep(secs)

方法描述
time.sleep(secs)程序暂停执行指定的秒数
'''
time.sleep(secs)
	参数:
		secs:推迟执行的秒数
		
	Delay execution for a given number of seconds.  The argument may be
    a floating point number for subsecond precision.
'''
time.sleep(1)

1.2、time.time()

方法描述
time.time()返回当前系统时间的时间戳(从1970年1月1日午夜(UTC/GMT)到当前时间的秒数,是一个浮点数,包括秒数和小数部分,小数部分表示更精确的时间。)
'''
time.time()
	无参数
	
	Delay execution for a given number of seconds.  The argument may be
    a floating point number for subsecond precision.
'''
start = time.time()
print(start)  # 1720171791.0012453

1.3、time.time_ns()

方法描述
time.time_ns()获取当前的纳秒级时间戳
'''
time.time_ns()
	无参数
	
	Return the current time in nanoseconds since the Epoch.
'''
start = time.time_ns()
print(start)  # 1720406402195668200

1.4、time.clock()

方法描述
time.clock()用于测量CPU时间,比较精准,通过比较程序运行前后的CPU时间差,得出程序运行的CPU时间。一般用于性能测试、算法效率比较等场景

注意:time.clock()在某些版本中已被标记为废弃。这里不做过多的介绍。

1.5、time.process_time()

方法描述
time.process_time()当前进程的系统和用户CPU时间之和的值(以秒为单位)。
'''
time.process_time()
	无参数
	
	Process time for profiling: sum of the kernel and user-space CPU time.
'''
start_time = time.process_time()

time.sleep(1)  # 不计算
list = [i for i in range(2 ** 20)]

end_time = time.process_time()

print("程序执行时间为:{} - {} = {}".format(end_time, start_time, end_time - start_time))
# 程序执行时间为:0.046875 - 0.03125 = 0.015625

1.6、time.thread_time()

方法描述
time.process_time()当前线程的系统和用户CPU时间之和的值(以秒为单位)。
'''
time.process_time()
	无参数

	Thread time for profiling: sum of the kernel and user-space CPU time.
'''
import time

start_time = time.thread_time()

time.sleep(1)  # 不计算
list = [i for i in range(2 ** 20)]

end_time = time.thread_time()

print("程序执行时间为:{} - {} = {}".format(end_time, start_time, end_time - start_time))
# 程序执行时间为:0.046875 - 0.03125 = 0.015625
Onnxruntime之YOLOP部署过程记录 魔改YoloP部署过程记录 阅读详情

相关推荐

STM32控制舵机SG-5010转动,HAL库

首先设置时钟为72Mhz,预分频系数为72-1,自动重装载计数器的值为5000-1,这样的话就可以得到一个5ms的脉冲宽度,5000的计数值可以让舵机的旋转角度变得更加易控且相对精准,计算旋转角度的时候也可以更加精确。所以我们5ms脉宽,period是5000脉宽-------------角度----------pulse0.5ms-------------0度----------500;1.0ms------------45度---------1000;

qq_73783264的博客 1292

python的魔术方法大全

python的魔术方法大全   在Python中,所有以“__”双下划线包起来的方法,都统称为“Magic Method”(魔术方法),例如类的初始化方法 __init__ ,Python中所有的魔术方法均在官方文档中有相应描述,这边给大家把所有的魔术方法汇总了一下,希望对大家的学习有所帮助。二、属性相关的魔法方法......

henry_rhy的博客 6678

nRF52811墨水屏时钟DIY:从全刷到局刷的实战改造指南(附完整代码)

本文详细介绍了如何将基于nRF52811的墨水屏时钟从耗电的全屏刷新模式改造为高效的局部刷新模式。通过剖析全刷与局刷的原理差异,提供了从工程架构、驱动层适配到应用层逻辑重构的完整实战指南,并附上关键代码示例。改造后,设备功耗显著降低,续航大幅提升,同时解决了视觉闪烁问题,是DIY低功耗墨水屏应用的实用参考。

weixin_29194693的博客 355

Python字典使用方法大全

Python字典使用方法大全 python中还有一种数据结构特别重要,就是字典。字典是键(key)-值(value)一一对应组成。这样的键-值组合叫做项。键与值之间用‘:’分隔,项之间用‘,’分隔。 字典是用花括号‘{}’表示。说到这,要区别一下,列表用‘[ ]’表示,元组用‘()’表示。 首先,我们来看看如何创建字典。 #这里用电话簿实例 phonebook = {'A': '1234567', 'B': '223344556', 'C': '334455667'} A = phonebook['A']

Francisca13的博客 5276

【博客汇总】UV打印机博客汇总

UV平板机博客汇总

Print World的专栏 1740

MFC下使用C++操作Word文档

由于项目需求,在MFC环境下操作将数据和图片写入word文档,之前没有接触过,网上查阅了很多资料,终于把任务完成。理解的不是很透彻,但是这些东西应该够用了,写篇博客记录一下,以便以后再用到。 (1)VS环境下创建一个MFC应用程序,然后在项目上单击右键,选择 类向导-----添加类----类型库中的MFC类。在弹出的对话框中选择文件,位置选择office安装目录下的...

GIS_yuhua的博客 7579

python经典算法大全,python算法有哪些

这篇文章主要介绍了python经典算法大全,具有一定借鉴价值,需要的朋友可以参考下。希望大家阅读完这篇文章后大有收获,下面让小编带着大家一起了解一下。

2301_81900386的博客 2555

【RT-DETR涨点改进】独家创新改进篇 | AAAI2024 | RT-DETR引入CFBlock增强对长程依赖和全局语义信息的建模能力,有助于提升复杂场景下小目标、遮挡目标的检测精度

本文给大家介绍在RT-DETR中引入CFBlock模块,能够有效提升模型对长程依赖和全局语义信息的建模能力,在保持轻量化和高效推理的基础上增强特征表达力,特别有助于提升复杂场景下小目标、遮挡目标的检测精度,从而实现更优的精度与速度平衡。

Ai缝合怪、助力小伙伴高效发论文 260

python命令大全及说明,python常用指令大全

1 在cmd下 盘与盘之间的切换 直接 D或d: 就好2 查找当前盘或者文件下面的目录 直接 dir3 想在一个盘下进去一个文件夹,用cd空格目标文件 cd p4 写文件的第一个字母后 按tab键自动补全 如果有多个p开头的则在按tab 会在所有之间切换5 d:切盘 dir 查找目录 cd 进去目标文件(相当于双击)6 往上走一层 cd .. 走两层 cd ../..(之间有无空格都行)

2301_81895949的博客 2080

uniapp - 微信授权登录报错 errMsg“:“login:fail send“ | “code“:-100 | “innerCode“:-6,解决uni-app调用微信登录时没有响应且返回错误

uni-app,微信登录,微信登录报错,微信小程序,支付宝小程序,安卓app,苹果ios,nvue,H5网页网站,uniapp苹果安卓app,微信授权登录,uniAppAPP端微信登录报错,微信确认登录界面后点击登录报错,"errMsg":"login:failsend","errCode":-100,"code":-100,"innerCode":-6,都配置好了还是报错怎么办,uniapp微信授权登录报错,UniApph5对接微信登录出现错误,appid,应用签名,微信登陆,code:-100

🏆 前端领域优质创作者 1万+

手眼标定----眼在手上(eye-in-hand)

@TOC 标定之前你可以先拿个怡宝盖子进行测试。 第一步:打开halcon,采集,然后生成代码,显示十字架 第二步:把怡宝盖子放在十字架中心位置,在图像处理,找到怡宝盖子 第三步:找到怡宝盖子然后进行九点标定(眼在外帖子有讲),移动机器手然后分别拍9次照片,记录怡宝盖子坐标和当前机器坐标。这里移动到中心位置的时候记录一下单独记录一下坐标,等下要用。 顺序 第四步:拍完后利用vector_to_hom_mat2d算子求出矩阵,然后在利用write_tuple (HomMat2D, ‘路径’)进行保存。这里

苏州程序大白的博客 4280

Python魔术方法大全

在Python中,所有以“__”双下划线包起来的方法,都统称为“Magic Method”(魔术方法),例如类的初始化方法 __init__ ,Python中所有的魔术方法均在官方文档中有相应描述,这边给大家把所有的魔术方法汇总了一下,希望对大家的学习有所帮助。

记录学习路上的一些拙见 1878

2026年03月CCF-GESP编程能力等级认证C++编程一级真题解析

本文收录于专栏《。订阅后可阅读专栏内所有文章。

人生就是一个不断学习的过程 337

python命令大全及说明,python命令大全下载

Python 是一门独特的语言,快速浏览一下他的要点:面向对象:每一个变量都是一个类,有其自己的属性(attribute)与方法(method)。语法块:用缩进(四个空格)而不是分号、花括号等符号来标记用python画笑脸表情。因此,行首的空格不能随意书写。注释:行内用“#”号,行间注释写在两组连续三单引号之间:’’’续行:行尾输入一个反斜杠加一个空格(’\ ‘),再换行。如果行尾语法明显未完成(比如以逗号结尾),可以直接续行。

gk12336的博客 955

SAP B1中文培訓教材_SDK

公司内部培训资料,对开发工具 ,DIAPI, UIAPI,Add-ON有详细解说

Data-Structures-and-Algorithm-Analysis-in-Java.pdf

作者: Weiss, Mark A. 出版社: Addison Wesley Data Structures and Algorithm Analysis in Java is an “advanced algorithms” book that fits between traditional CS2 and Algorithms Analysis courses. In the old ACM Curriculum Guidelines, this course was known as CS7. This text is for readers who want to learn good programming and algorithm analysis skills simultaneously so that they can develop such programs with the maximum amo...

python代码大全和用法,python代码大全简单

今天要介绍的是一个专注提供Python有用代码片段的网站:这个项目试图提供许多Python代码,使生活变得更容易,同时项目旨在收集有用的Python片段,以增强pythoneers的编码体验。访问者可以很容易地找到自己需要的代码样例python四瓣花怎么画。这些代码样例无论对于项目编程还是语言学习都很有帮助。备忘单这个部分主要讨论Python代码中常见的代码片段。备忘单不仅包括基本的Python特性,还包括数据结构和算法。高级备忘单这个部分的目标是给出常见的片段,包括内置和第三方模块的使用。附录。

P5688346的博客 911

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

python代码大全简单,python的代码大全

大家好,本文将围绕python代码大全简单展开说明,python的代码大全是一个很多人都想弄明白的事情,想搞清楚“python代码”需要先了解以下几个事情。

2401_82891043的博客 1211

TMS_WebGMaps_1.9.8.0_Full_Source

TMS_WebGMaps_1.9.8.0_Full_Source 全源码 delphi cbuilder

python代码大全和用法,python编程常用代码

这篇文章主要介绍了python代码大全和用法,具有一定借鉴价值,需要的朋友可以参考下。希望大家阅读完这篇文章后大有收获,下面让小编带着大家一起了解一下。

S1112_的博客 1062

python之列表方法大全

文章目录列表方法1、append在特定的列表最后添加一个元素,并且只能一次添加一个元素,并且只能在列表最后。2、clear清空列表,使列表变成一个空的。3、copy返回列表对象的浅拷贝3.1、deepcopy返回列表对象的深拷贝4、count数据所在列表中出现的次数5、extend将列表 alist 所有元素加到列表 list 尾部注意与链接操作的不同之处6、index返回第一个 x 的索引位置,若不存在 x 元素抛出异常7、insert在列表 list 指定位置 index 处插入元素 x。8、pop删除

Qiu先生的博客 2945

python方法大全_python的 __等方法大全

1,__new__执行在构造方法__init__之前2,python默认用__new__创建类的实例,3,最终结果要返回__init__方法,可以不返回当前类的实例,4,__new__是类的静态方法,虽然没有加上装饰器class Foo(object):def __init__(self, *args, **kwargs):...def __new__(cls, *args, **kwargs):...

weixin_39714275的博客 637

python列表常用方法大全

列表(List)是 Python 中最常用的数据结构之一,它是一个有序、可变的集合,可以存储任意类型的元素。以下是列表的定义及常见用法,包括拼接、增加数据、插入数据、删除数据、计算差值、相加、清空等操作,与字典和pandas结合使用场景比较多。

肖永威的专栏 4287

python大全

python大全 看完绝对ok 里面什么都有!!!

ljm_99的博客 238

Python组件库大全

Python组件库大全

4849

python命令大全下载,python基本命令大全

1 在cmd下 盘与盘之间的切换 直接 D或d: 就好2 查找当前盘或者文件下面的目录 直接 dir3 想在一个盘下进去一个文件夹,用cd空格目标文件 cd p4 写文件的第一个字母后 按tab键自动补全 如果有多个p开头的则在按tab 会在所有之间切换5 d:切盘 dir 查找目录 cd 进去目标文件(相当于双击)6 往上走一层 cd .. 走两层 cd ../..(之间有无空格都行)

Fixf4556的博客 998

Python类中的属性和方法大全

Python类中的属性和方法大全 文章目录Python类中的属性和方法大全1.特殊属性:2.方法2.1特殊内建函数与查看属性2.2实例化2.3可视化2.4可哈希(hash)与等等运算符(==)2.5bool3运算符重载3.1比较运算符重载3.2算术运算符重载3.3反向运算符重载3.4赋值运算符的重载4.容器相关方法5.可调用对象6.上下文管理7.反射8.反射 1.特殊属性: 属性 含义 ...

兰枫 3239
上一篇: Linux Vim 最全面教程(Linux)
下一篇: 生成随机的验证码图片(Python)
-O-joker
博客等级 码龄5年 2978粉丝 108原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

-O-joker

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值