__init的用法

init的用法 有时候我们不希望用户直接访问包内的某些模块,可以通过__init__.py进行接口封装,然后使用__all__变量进行控制。 阅读详情
在kernel中有很多__init,这个东东到底是何方神圣捏?且听小生我一一道来。
下面是其定义:
file:/include/linux/init.h
 43 #define __init      __attribute__ ((__section__ (".init.text"))) __cold
 44 #define __initdata  __attribute__ ((__section__ (".init.data")))
 45 #define __exitdata  __attribute__ ((__section__(".exit.data")))
 46 #define __exit_call __attribute_used__ __attribute__ ((__section__ (".exitcall.exit")))

也许你会问那 __attribute__ ((__section__ (".init.text"))) __cold是什么东东阿?
且看 info gcc C Extensions Attribute Syntax
section ("SECTION-NAME")'
     Normally, the compiler places the objects it generates in sections
     like `data' and `bss'.  Sometimes, however, you need additional
     sections, or you need certain particular variables to appear in
     special sections, for example to map to special hardware.  The
     `section' attribute specifies that a variable (or function) lives
     in a particular section.  For example, this small program uses
     several specific section names:
          struct duart a __attribute__ ((section ("DUART_A"))) = { 0 };
          struct duart b __attribute__ ((section ("DUART_B"))) = { 0 };
          char stack[10000] __attribute__ ((section ("STACK"))) = { 0 };
          int init_data __attribute__ ((section ("INITDATA"))) = 0;

          main()
          {
            /* Initialize stack pointer */
            init_sp (stack + sizeof (stack));

            /* Initialize initialized data */
            memcpy (&init_data, &data, &edata - &data);

            /* Turn on the serial ports */
            init_duart (&a);
            init_duart (&b);
          }

     Use the `section' attribute with an _initialized_ definition of a
     _global_ variable, as shown in the example.  GCC issues a warning
     and otherwise ignores the `section' attribute in uninitialized
     variable declarations.

     You may only use the `section' attribute with a fully initialized
     global definition because of the way linkers work.  The linker
     requires each object be defined once, with the exception that
     uninitialized variables tentatively go in the `common' (or `bss')
     section and can be multiply "defined".  You can force a variable
     to be initialized with the `-fno-common' flag or the `nocommon'
     attribute.

     Some file formats do not support arbitrary sections so the
     `section' attribute is not available on all platforms.  If you
     need to map the entire contents of a module to a particular
     section, consider using the facilities of the linker instead.

简单来说是指示gcc把标记的数据或者函数放到指定sector。
linux中把一些启动及初始化时候用的数据用__init标识,然后在适当的时候把它们释放,回收内存。
说到这个__init,就不能不说module_init,subsys_initcall。
在init.h中我们能够找到 #define subsys_initcall(fn)     __define_initcall("4",fn,4)
又是一个宏定义,简直是无极中的圆环套圆环之城阿。
file:/include/linux/init.h
100 /* initcalls are now grouped by functionality into separate
101  * subsections. Ordering inside the subsections is determined
102  * by link order. 
103  * For backwards compatibility, initcall() puts the call in 
104  * the device init subsection.
105  *
106  * The `id' arg to __define_initcall() is needed so that multiple initcalls
107  * can point at the same handler without causing duplicate-symbol build errors.
108  */
109 

110 #define __define_initcall(level,fn,id) /
111     static initcall_t __initcall_##fn##id __attribute_used__ /
112     __attribute__((__section__(".initcall" level ".init"))) = fn


subsys_initcall(usb_init)转换后就变成了 static initcall_t  __initcall_usbinit4   __attribute_used__ /
__attribute__((__section__(".initcall 4.init"))) = usb_init
就是把usb_init的函数入口指针存放在.initcall4.init中。
file:/include/asm-generic/vmlinux.lds.h
239 #define INITCALLS                           /
240     *(.initcall0.init)                      /
241     *(.initcall0s.init)                     /
242     *(.initcall1.init)                      /
243     *(.initcall1s.init)                     /
244     *(.initcall2.init)                      /
245     *(.initcall2s.init)                     /
246     *(.initcall3.init)                      /
247     *(.initcall3s.init)                     /
248     *(.initcall4.init)                      /
249     *(.initcall4s.init)                     /
250     *(.initcall5.init)                      /
251     *(.initcall5s.init)                     /
252     *(.initcallrootfs.init)                     /
253     *(.initcall6.init)                      /
254     *(.initcall6s.init)                     /
255     *(.initcall7.init)                      /
256     *(.initcall7s.init)


file:/arch/kernel/vmlinux_32.lds.S
144   .initcall.init : AT(ADDR(.initcall.init) - LOAD_OFFSET) {
145     __initcall_start = .;
146     INITCALLS
147     __initcall_end = .;
148   }

展开
   .initcall.init : AT(ADDR(.initcall.init) - LOAD_OFFSET) {
     __initcall_start = .;
     *(.initcall0.init)                      /
     *(.initcall0s.init)                     /
     *(.initcall1.init)                      /
     *(.initcall1s.init)                     /
     *(.initcall2.init)                      /
     *(.initcall2s.init)                     /
     *(.initcall3.init)                      /
     *(.initcall3s.init)                     /
     *(.initcall4.init)                      /
     *(.initcall4s.init)                     /
     *(.initcall5.init)                      /
     *(.initcall5s.init)                     /
     *(.initcallrootfs.init)                     /
     *(.initcall6.init)                      /
     *(.initcall6s.init)                     /
     *(.initcall7.init)                      /
     *(.initcall7s.init)
     __initcall_end = .;
   }


那么系统是如何执行这些函数呢?
此话就长了阿~ 话说盘古开天芙蓉姐姐补天后我们来到了main.c这个linux中举足轻重的文件
进入start_kernel
start_kernel  -->rest_init() -->kernel_init()  --> do_basic_setup()  -->do_initcalls()

这个do_initcalls()就是调用这些函数的地方。
file:/init/main.c
662 static void __init do_initcalls(void)
663 {
664     initcall_t *call;
665     int count = preempt_count();
666 
667     for (call = __initcall_start; call < __initcall_end; call++) {
668         ktime_t t0, t1, delta;
669         char *msg = NULL;
670         char msgbuf[40];
671         int result;
672 
673         if (initcall_debug) {
674             printk("Calling initcall 0x%p", *call);
675             print_fn_descriptor_symbol(": %s()",
676                     (unsigned long) *call);
677             printk("/n");
678             t0 = ktime_get();
679         }
680 
681         result = (*call)();
682 
683         if (initcall_debug) {
684             t1 = ktime_get();
685             delta = ktime_sub(t1, t0);
686 
687             printk("initcall 0x%p", *call);
688             print_fn_descriptor_symbol(": %s()",
689                     (unsigned long) *call);
690             printk(" returned %d./n", result);
691 
692             printk("initcall 0x%p ran for %Ld msecs: ",
693                 *call, (unsigned long long)delta.tv64 >> 20);
694             print_fn_descriptor_symbol("%s()/n",
695                 (unsigned long) *call);
696         }
697 
698         if (result && result != -ENODEV && initcall_debug) {
699             sprintf(msgbuf, "error code %d", result);
700             msg = msgbuf;
701         }
702         if (preempt_count() != count) {
703             msg = "preemption imbalance";
704             preempt_count() = count;
705         }
706         if (irqs_disabled()) {
707             msg = "disabled interrupts";
708             local_irq_enable();
709         }
710         if (msg) {
711             printk(KERN_WARNING "initcall at 0x%p", *call);
712             print_fn_descriptor_symbol(": %s()",
713                     (unsigned long) *call);
714             printk(": returned with %s/n", msg);
715         }
716     }
717 
718     /* Make sure there is no pending stuff from the initcall sequence */
719     flush_scheduled_work();
720 }
【Unity 反向运动学插件】Final IK 一套完整的IK解决方案 Final IK是Unity中一套完整的反向运动学解决方案,提供多种IK算法(CCD、FABRIK等)和功能模块,包括全身IK、VR驱动、武器瞄准、视线跟随等。其核心是通过数学方法计算关节旋转,使末端骨骼精确到达目标位置。系统支持多约束求解、旋转限制、动画烘焙及交互系统,采用模块化设计,兼顾性能与扩展性,适用于动作游戏、VR等需要高质量角色控制的场景,是Unity生态中最成熟的IK工具链之一。 阅读详情

相关推荐

用Keil5给CH552G编程:手把手配置8051开发环境+LED闪烁实战

本文详细介绍了如何使用Keil5为CH552G单片机配置8051开发环境,并完成LED闪烁实战。从获取必要软件、安装WCH器件库到创建工程、编写程序及烧录,手把手指导开发者避开常见陷阱,特别适合从STC转向CH552G的开发者。

weixin_30733003的博客 538

linux的initcall机制,嵌入式开发--STM32上实现驱动注册initcall机制(类linux)

一、前言上一节我们实现了代码应用层和硬件层的分离管理,但是代码中还存在一个问题,每个硬件如LED控制,GPIO口需要初始化,初始化函数bsp_led_init();这个函数需要在主函数中调用初始化,类似这样:void bsp_init(void){bsp_rcc_init();bsp_tick_init();bsp_led_init();bsp_usart_init();}这样存在的问题是:当有很...

weixin_33231849的博客 463

HighScore3.0实战指南:XRD物相分析从入门到精通(持续更新版)

本文提供HighScore3.0软件进行XRD物相分析的完整实战指南。从软件设置、数据导入、背景扣除、寻峰等预处理步骤,到核心的Search & Match物相搜索匹配、Rietveld精修定量,以及结果输出与常见问题排查,系统讲解了从入门到精通的全流程操作与核心技巧,帮助用户高效完成材料物相鉴定与分析工作。

weixin_29310605的博客 1043

嵌入式开发--STM32上实现驱动注册initcall机制(类linux)

一、前言 上一节我们实现了代码应用层和硬件层的分离管理,但是代码中还存在一个问题,每个硬件如LED控制,GPIO口需要初始化,初始化函数bsp_led_init();这个函数需要在主函数中调用初始化,类似这样: void bsp_init(void) { bsp_rcc_init(); bsp_tick_init(); bsp_led_init(); ...

SunnyBit的博客 2169

RAGFlow API 实战指南:从数据集管理到智能对话

本文提供了RAGFlow API的实战指南,详细介绍了如何从零开始构建基于检索增强生成(RAG)的智能应用。内容涵盖环境准备、API密钥获取、核心概念理解,以及通过API进行数据集创建与管理、文档上传解析、知识块管理、检索测试,最终创建并配置智能聊天助手,实现基于私有知识库的精准对话。

weixin_29284885的博客 379

基于ROS2系统开发机器人

以上是基于ROS 2开发机器人的基本流程和一个简单的发布者-订阅者示例。通过这个流程,你可以逐步扩展和优化你的机器人系统,实现更复杂的功能。

xuweilin的博客 1494

STM32上实现驱动注册initcall机制

转载:STM32上实现驱动注册initcall机制 一、代码 实现了代码应用层和硬件层的分离管理,但是代码中还存在一个问题,每个硬件如LED控制,GPIO口需要初始化,初始化函数bsp_led_init();这个函数需要在主函数中调用初始化,类似这样: void bsp_init(void) { bsp_rcc_init(); bsp_tick_init(); bsp_led_init(); bsp_usart_init(); } 这样存在的问...

如梦人身 880

OpenCV 实战篇——如何测算出任一副图片中的物体的实际尺寸?传感器尺寸与像元尺寸的关系?

本文介绍了通过相机图像测算物体实际尺寸的方法,重点分析了传感器参数与成像质量的关系。文章首先给出了物体实际尺寸的计算公式,涉及像素尺寸、距离、分辨率等参数。然后详细解析了传感器尺寸与像元尺寸的关系,指出相同分辨率下更大的传感器能获得更好的成像质量。此外还介绍了光学尺寸、像素尺寸对成像的影响,以及帧率的概念。最后提及了相机标定的重要性,并概述了从像素坐标系转换到世界坐标系的基本思路。这些知识为通过相机图像进行精确测量提供了理论基础。

程序员,他们想的是什么?他们想的永远都是技术,他们崇尚的也永远都是技术。 1335

嵌入式大杂烩周记 | 第 4 期:cola_os

大家好,我是ZhengN。嵌入式大杂烩周记主要是一些实用项目学习分享,每周一篇,每篇一个主题。内容主要来源于我们之前收集的资料:https://gitee.com/zhengnianli/...

嵌入式大杂烩 1793

姿态传感器/陀螺仪之IIS2DLPC 应用驱动程序设计

* 转换为°C单位 (参考温度为25°C,灵敏度为16 LSB/°C) */

corlin6688的博客 219

如何在 R 中使用 Gamma 分布(附示例)

在统计学中,伽马分布通常用于模拟与等待时间相关的概率。我们可以使用以下函数来处理 R 中的 gamma 分布:dgamma(x, shape, rate) – 找到具有特定形状和速率参数的 gamma 分布的密度函数值。 pgamma(q, shape, rate) – 找到具有特定形状和速率参数的伽马分布的累积密度函数值。 qgamma(p, shape, rate) – 找到具有特定形状和速率参数的 gamma 分布的逆累积密度函数值。 rgamma(n, shape, rate) – 生成 n 个随机

Mrrunsen的博客 4415

各种initcall的执行先后顺序(module_init、postcore_initcall、arch_initcall、subsys_initcall、 fs_initcall)

现在以module_init为例分析initcall在内核中的调用顺序 在头文件init.h中,有如下定义: #define module_init(x)     __initcall(x); 很明显,module_init()只是一个面具而已,揭开这个面具,下面藏着的是_

fenzhikeji的专栏 3万+

从零开始:使用Verilog在FPGA上实现8051微控制器的完整指南

8051微控制器是一种8位微控制器,由Intel在1980年代初推出。它包括一个CPU、一些RAM和ROM、I/O端口、定时器和串行通信接口。由于其简单的架构和强大的功能,8051已经成为了嵌入式系统设计的首选。FPGA是一种集成电路,设计师可以按照自己的需求进行编程。与传统的ASIC(应用特定集成电路)相比,FPGA提供了更高的灵活性,允许在硬件级别进行快速原型设计和迭代。这里,我们定义了一些基本的输入/输出端口,如时钟clk、复位reset、数据输入/输出和地址输入/输出。

qq_38334677的博客 1330

git init 用法

概述 Git 使用 git init 命令创建一个空的仓库,基本上就是在当前目录下创建一个 .git 目录,目录下面存储着仓库的各项信息。 在一个已经创建过 Git 仓库的目录下执行 git init 命令也是没有问题的,它不会去重写任何已经存在的内容。最主要的原因,在已有的 Git 仓库下执行该命令就是获取新添加的模板。 如果带上路径执行 git init <path> 命令,它会在......

bluebird_shao的专栏 1359

Probability and Statistics - 4th edition

Probability and Statistics - 4th edition

win10 跳过U8环境检测的IE WebControls.rar

win10 安装u8的时候 提示IE WebControls 不通过,这个工具可以欺骗u8的检查。 跳过U8环境检测的IE WebControls。提示导入失败后,重新检测通过。

Python 中的 __init__ 方法高级用法详解

_init__方法是 Python 中一个非常强大的工具,它不仅可以用于初始化对象的属性,还可以实现很多高级用法。通过合理地使用__init__方法,我们可以提高代码的可读性、可维护性和性能。希望本文对你理解和运用__init__方法有所帮助。

liuhailong0511的博客 1611

深度学习工具包 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 init 用法_python里init的用法

python中的__init__()是什么意思呢python为什么要有一个init函数 知乎Python中“__init__”的意义是什么?python脚本下面的 __init__.py 有什么作用呢The __init__.py files are required to make Python treat the directories as containing packages; this...

weixin_39567046的博客 491

计算机控制技术及应用

《计算机控制技术及应用》通过总结作者的科研成果和吸收国内外的先进理论、方法和技术,以计算机控制系统的网络化、开放化、智能化和集成化发展趋势为主线索,主要介绍计算机控制系统的基本概念和计算机控制系统的典型形式,计算机控制系统的数学描述与基本分析方法,以及数字PID控制器、最少拍控制系统、达林算法、状态变量设计法等设计方法及其各种改进算法。重点突出计算机控制系统输入输出通道接口的设计方法和典型控制系统的设计案例与实现方法等。

Python中 __init__()用法

首先: class Person: def __init__(self, name, age): self.name = name self.age = age class关键字后面跟类的名称就定义了一个类,类的名称可以任意,采用驼峰命名法,也即每个单词的首字母大写,如Book、Person、WildAnimal等这里的__init__方法是一个特殊的方法...

qq_36979522的博客 1175

【python】__init__.py的用法

__init__.py学习理解

热爱生活、热爱技术、热爱记录~ 3877

python init文件 all_Python __init__ 用法

学习Python的过程中,__init__ 的用法是一个难点,即使许多Python的书籍上,关于Python __init__ 用法也是写得十分拗口、难懂,今天终于找到一个关于Python __init__ 用法说明,我觉得说得很透彻,分享给大家。一、不用__init__方法也是可以的。比如,定义一个矩形的类,目的是求周长和面积。class Rectangle():def getPeri(self...

weixin_39740419的博客 344

__init__在python中的用法包_Python包,__init__.py功能与用法分析

本文实例讲述了Python包,__init__.py功能与用法。分享给大家供大家参考,具体如下:包:为了组织好模块,将多个模块组合为一个包,所以包用于存放python模块包通常是一个文件夹,当文件夹当作包使用时,文件夹需要包含__init__.py文件__init__.py的内容可以为空,一般用来进行包的某些初始化工作或者设置__all__值,__all__是在from ...import *语句...

weixin_39639286的博客 235

linux命令——init 的使用用法

有很多小伙伴们不知道init命令的使用方法,还有些小伙伴不清楚linux系统的切换图形化和命令行等模式的方法。通过简单的init命令可以轻松实现哦。

我的博客 3万+

Python中_init_的用法和理解

Python中_init_的用法和理解 在Python中定义类经常会用到_init_函数(方法),首先需要理解的是,两个下划线开头的函数是声明该属性为私有,不能在类的外部被使用或者访问。而_init_函数(方法)支持带参数类的初始化,也可为声明类的属性(类中的变量)。_init_函数(方法)的第一个参数必须为self,后续参数为自己定义。 ...

weixin_40852277的博客 595

sem_init函数用法

sem_init函数 sem_init函数是Posix信号量操作中的函数。sem_init() 初始化一个定位在 sem 的匿名信号量。value 参数指定信号量的初始值。 pshared 参数指明信号量是由进程内线程共享,还是由进程之间共享。如果 pshared 的值为 0,那么信号量将被进程内的线程共享,并且应该放置在这个进程的所有线程都可见的地址上(如全局变量,或者堆上动态分配的变量)。 如果 pshared 是非零值,那么信号量将在进程之间共享,并且应该定位共享内存区域(见 shm_open(3)

weixin_42832472的博客 1万+

__init__在python中的用法知乎_Python中__init__的用法和理解

在Python中定义类经常会用到__init__函数(方法),首先需要理解的是,两个下划线开头的函数是声明该属性为私有,不能在类的外部被使用或访问。而__init__函数(方法)支持带参数类的初始化,也可为声明该类的属性(类中的变量)。__init__函数(方法)的第一个参数必须为self,后续参数为自己定义。从文字理解比较困难,通过下面的例子能非常容易理解这个概念:例如我们定义一个Box类,有w...

weixin_39785814的博客 252

super().__init__()用法

优先阅读:这个是我这个菜鸟自己理解的,误导别人概不负责~哈哈哈哈哈哈哈 一、何时要使用super.__init__():   我理解是,当需要继承父类构造函数中的内容,且子类需要在父类的基础上补充时,使用super().__init__()方法。 在这段代码中,New_person这个类即需要用到父类中name和age,又需要新增sex这个参数。这时就需要用到super().__init...

weixin_30276935的博客 6793

Python中__init__.py的用法说明

在Python中,文件是定义包(Package)的核心组件。

qq_17275369的博客 1053
上一篇: gpio_request的使用
下一篇: 基本数据结构:链表(list)
Jason-25
博客等级 码龄17年 10粉丝 0原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值