Multi-line Comments in Python / Python中的多行注释

本文探讨了Python中的注释方法,特别是在Python中缺乏多行注释语法的情况下如何有效地使用单行注释及字符串来达到注释的目的。作者还讨论了将不需要的代码段用三引号括起来的方法,尽管这种方法实际上被解释为字符串而非注释。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

So interesting is python...

I'm gonna record down what I find in python while I'm learning it.

 

The first one is...... the comment

When I was trying to "comment" some lines of code, I found there was only line comments in python. There isn't syntax of multi-line comment like "/*..*/" in C, in Python.

Then I came up with an idea, there did exist a method to make some lines "invalid" which is to put them into quotes. Just like this:

"""

print 'THIS IS WHAT I DONT NEED CURRENTLY"

"""

In fact this is not any kind of  "comment". It would be intepreted as a string and have an negative affect upon effeciency. As python is slow indeed, certainly the case can be ignored:)

 
注释改成英文 #include "pid.h" /** * @brief pid初始化 * @param 无 * @retval 无 */ void pid_init(PID_TypeDef *pid) { pid->SetPoint = 0; /* 设定目标值 */ pid->ActualValue = 0.0; /* 期望输出值 */ pid->SumError = 0.0; /* 积分值 */ pid->Error = 0.0; /* Error[1] */ pid->LastError = 0.0; /* Error[-1] */ pid->PrevError = 0.0; /* Error[-2] */ pid->Proportion = KP; /* 比例常数 Proportional Const */ pid->Integral = KI; /* 积分常数 Integral Const */ pid->Derivative = KD; /* 微分常数 Derivative Const */ } /** * @brief pid闭环控制 * @param *PID:PID结构体变量地址 * @param Feedback_value:当前实际值 * @retval 期望输出值 */ int32_t increment_pid_ctrl(PID_TypeDef *PID,float Feedback_value) { PID->Error = (float)(PID->SetPoint - Feedback_value); /* 计算偏差 */ #if INCR_LOCT_SELECT /* 增量式PID */ PID->ActualValue += (PID->Proportion * (PID->Error - PID->LastError)) /* 比例环节 */ + (PID->Integral * PID->Error) /* 积分环节 */ + (PID->Derivative * (PID->Error - 2 * PID->LastError + PID->PrevError)); /* 微分环节 */ PID->PrevError = PID->LastError; /* 存储偏差,用于下次计算 */ PID->LastError = PID->Error; #else /* 位置式PID */ PID->SumError += PID->Error; PID->ActualValue = (PID->Proportion * PID->Error) /* 比例环节 */ + (PID->Integral * PID->SumError) /* 积分环节 */ + (PID->Derivative * (PID->Error - PID->LastError)); /* 微分环节 */ PID->LastError = PID->Error; #endif return ((int32_t)(PID->ActualValue)); /* 返回计算后输出的数值 */ }
03-17
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值