Arduino - 按钮 - 长按短按

Arduino - Button - Long Press Short Press Arduino - 按钮 - 长按短按

Arduino - Button - Long Press Short Press

We will learn: 我们将学习:

  • How to detect the button’s short press
    如何检测按钮的短按
  • How to detect the button’s long press
    如何检测按钮的长按
  • How to detect both the button’s long press and short press
    如何检测按钮的长按和短按
  • Long press and short press with debouncing
    长按和短按带去弹跳

In the first three parts, we learn how to detect in principle.
在前三部分中,我们学习了如何原则上进行检测。

In the last part, we learn how to detect in practical use by applying the debounce. See why do we need to debounce for button. Without debouncing, we may detect wrong the button short press.
在最后一部分中,我们将学习如何通过应用去抖动来检测实际使用中的检测。看看为什么我们需要为按钮去抖动。如果不去抖动,我们可能会检测到错误的按钮短按。

Hardware Required 所需硬件

1×Arduino UNO or Genuino UNO Arduino UNO 或 Genuino UNO
1×USB 2.0 cable type A/B USB 2.0 电缆 A/B 型
1×Push Button 按钮
1×(Optional) Panel-mount Push Button (可选)面板安装按钮
1×Breadboard 面包板
1×Jumper Wires 跳线
1×(Optional) 9V Power Adapter for Arduino (可选)用于Arduino的9V电源适配器
1×(Recommended) Screw Terminal Block Shield for Arduino Uno (推荐)用于Arduino Uno的螺钉接线端子屏蔽层
1×(Optional) Transparent Acrylic Enclosure For Arduino Uno (可选)Arduino Uno透明亚克力外壳

About Button 关于按钮

If you do not know about button (pinout, how it works, how to program …), learn about them in the following tutorials:
如果您不了解按钮(引脚排列、工作原理、如何编程等),请在以下教程中了解它们:

  • Arduino - Button tutorial
    Arduino - 按钮教程

Wiring Diagram 接线图

Arduino Button Wiring Diagram

In this tutorial, we will use the internal pull-up resistor. Therefore, the state of the button is HIGH when normal and LOW when pressed.
在本教程中,我们将使用内部上拉电阻。因此,按钮的状态在正常时为高电平,按下时为低电平。

How To Detect Short Press 如何检测短按

We measure the time duration between the pressed and released events. If the duration is shorter than a defined time, the short press event is detected.
我们测量按下和发布事件之间的持续时间。如果持续时间短于定义的时间,则检测短按事件。

Let’s see step by step:
让我们一步一步地看:

  • Define how long the maximum of short press lasts
    定义短按的最大持续时间
const int SHORT_PRESS_TIME = 500; // 500 milliseconds 
  • Detect the button is pressed and save the pressed time
    检测按钮是否被按下并保存按下时间
if(lastState == HIGH && currentState == LOW)pressedTime = millis(); 
  • Detect the button is released and save the released time
    检测按钮已释放并保存释放时间
if(lastState == LOW && currentState == HIGH)releasedTime = millis(); 
  • Calculate press duration and
    计算按压持续时间和
long pressDuration = releasedTime - pressedTime; 
  • Determine the short press by comparing the press duration with the defined short press time.
    通过将按压持续时间与定义的短按压时间进行比较来确定短按。
if( pressDuration < SHORT_PRESS_TIME )  Serial.println("A short press is detected"); 

Arduino Code for detecting the short press 用于检测短按的Arduino代码

/** Created by ArduinoGetStarted.com** This example code is in the public domain** Tutorial page: https://arduinogetstarted.com/tutorials/arduino-button-long-press-short-press*/// constants won't change. They're used here to set pin numbers:
const int BUTTON_PIN = 7; // the number of the pushbutton pin
const int SHORT_PRESS_TIME = 500; // 500 milliseconds// Variables will change:
int lastState = LOW;  // the previous state from the input pin
int currentState;     // the current reading from the input pin
unsigned long pressedTime  = 0;
unsigned long releasedTime = 0;void setup() {Serial.begin(9600);pinMode(BUTTON_PIN, INPUT_PULLUP);
}void loop() {// read the state of the switch/button:currentState = digitalRead(BUTTON_PIN);if(lastState == HIGH && currentState == LOW)        // button is pressedpressedTime = millis();else if(lastState == LOW && currentState == HIGH) { // button is releasedreleasedTime = millis();long pressDuration = releasedTime - pressedTime;if( pressDuration < SHORT_PRESS_TIME )Serial.println("A short press is detected");}// save the the last statelastState = currentState;
}
Quick Steps 快速步骤
  • Upload the above code to Arduino via Arduino IDE
    通过Arduino IDE将上述代码上传到Arduino
  • Press the button shortly several times.
    短按按钮几次。
  • See the result on Serial Monitor
    在串行监视器上查看结果

※ NOTE THAT: ※ 注意事项:

The Serial Monitor may show several short press detection for one press. This is the normal behavior of the button. This behavior is called the “chattering phenomenon”. The issue will be solved in the last part of this tutorial.
串行监视器可能会显示一次按下的几次短按检测。这是按钮的正常行为。这种行为被称为“颤动现象”。该问题将在本教程的最后一部分解决。

How To Detect Long Press 如何检测长按

There are two use cases for detecting the long press.
检测长按有两个用例。

  • The long-press event is detected right after the button is released
    释放按钮后立即检测到长按事件
  • The long-press event is detected during the time the button is being pressed, even the button is not released yet.
    在按下按钮期间检测到长按事件,甚至按钮尚未松开。

In the first use case, We measure the time duration between the pressed and released events. If the duration is longer than a defined time, the long-press event is detected.
在第一个用例中,我们测量按下和发布事件之间的持续时间。如果持续时间超过定义的时间,则检测长按事件。

In the second use case, After the button is pressed, We continuously measure the pressing time and check the long-press event until the button is released. During the time button is being pressed. If the duration is longer than a defined time, the long-press event is detected.
在第二个用例中,按下按钮后,我们连续测量按下时间并检查长按事件,直到释放按钮。在按下时间按钮期间。如果持续时间超过定义的时间,则检测长按事件。

Arduino Code for detecting long press when released Arduino代码,用于在释放时检测长按

/** Created by ArduinoGetStarted.com** This example code is in the public domain** Tutorial page: https://arduinogetstarted.com/tutorials/arduino-button-long-press-short-press*/// constants won't change. They're used here to set pin numbers:
const int BUTTON_PIN = 7; // the number of the pushbutton pin
const int LONG_PRESS_TIME  = 1000; // 1000 milliseconds// Variables will change:
int lastState = LOW;  // the previous state from the input pin
int currentState;     // the current reading from the input pin
unsigned long pressedTime  = 0;
unsigned long releasedTime = 0;void setup() {Serial.begin(9600);pinMode(BUTTON_PIN, INPUT_PULLUP);
}void loop() {// read the state of the switch/button:currentState = digitalRead(BUTTON_PIN);if(lastState == HIGH && currentState == LOW)        // button is pressedpressedTime = millis();else if(lastState == LOW && currentState == HIGH) { // button is releasedreleasedTime = millis();long pressDuration = releasedTime - pressedTime;if( pressDuration > LONG_PRESS_TIME )Serial.println("A long press is detected");}// save the the last statelastState = currentState;
}
Quick Steps 快速步骤
  • Upload the above code to Arduino via Arduino IDE
    通过Arduino IDE将上述代码上传到Arduino
  • Press and release the button after one second.
    一秒钟后按下并松开按钮。
  • See the result on Serial Monitor
    在串行监视器上查看结果

The long-press event is only detected right after the button is released
只有在释放按钮后才能检测到长按事件

Arduino Code for detecting long press during pressing 用于在按压过程中检测长按的Arduino代码

/** Created by ArduinoGetStarted.com** This example code is in the public domain** Tutorial page: https://arduinogetstarted.com/tutorials/arduino-button-long-press-short-press*/// constants won't change. They're used here to set pin numbers:
const int BUTTON_PIN = 7; // the number of the pushbutton pin
const int LONG_PRESS_TIME  = 1000; // 1000 milliseconds// Variables will change:
int lastState = LOW;  // the previous state from the input pin
int currentState;     // the current reading from the input pin
unsigned long pressedTime  = 0;
bool isPressing = false;
bool isLongDetected = false;void setup() {Serial.begin(9600);pinMode(BUTTON_PIN, INPUT_PULLUP);
}void loop() {// read the state of the switch/button:currentState = digitalRead(BUTTON_PIN);if(lastState == HIGH && currentState == LOW) {        // button is pressedpressedTime = millis();isPressing = true;isLongDetected = false;} else if(lastState == LOW && currentState == HIGH) { // button is releasedisPressing = false;}if(isPressing == true && isLongDetected == false) {long pressDuration = millis() - pressedTime;if( pressDuration > LONG_PRESS_TIME ) {Serial.println("A long press is detected");isLongDetected = true;}}// save the the last statelastState = currentState;
}
Quick Steps 快速步骤
  • Upload the above code to Arduino via Arduino IDE
    通过Arduino IDE将上述代码上传到Arduino
  • Press and release the button after several seconds.
    几秒钟后按下并松开按钮。
  • See the result on Serial Monitor
    在串行监视器上查看结果

How To Detect Both Long Press and Short Press 如何检测长按和短按

Short Press and Long Press after released 发布后短按和长按

/** Created by ArduinoGetStarted.com** This example code is in the public domain** Tutorial page: https://arduinogetstarted.com/tutorials/arduino-button-long-press-short-press*/// constants won't change. They're used here to set pin numbers:
const int BUTTON_PIN = 7; // the number of the pushbutton pin
const int SHORT_PRESS_TIME = 1000; // 1000 milliseconds
const int LONG_PRESS_TIME  = 1000; // 1000 milliseconds// Variables will change:
int lastState = LOW;  // the previous state from the input pin
int currentState;     // the current reading from the input pin
unsigned long pressedTime  = 0;
unsigned long releasedTime = 0;void setup() {Serial.begin(9600);pinMode(BUTTON_PIN, INPUT_PULLUP);
}void loop() {// read the state of the switch/button:currentState = digitalRead(BUTTON_PIN);if(lastState == HIGH && currentState == LOW)        // button is pressedpressedTime = millis();else if(lastState == LOW && currentState == HIGH) { // button is releasedreleasedTime = millis();long pressDuration = releasedTime - pressedTime;if( pressDuration < SHORT_PRESS_TIME )Serial.println("A short press is detected");if( pressDuration > LONG_PRESS_TIME )Serial.println("A long press is detected");}// save the the last statelastState = currentState;
}
Quick Steps 快速步骤
  • Upload the above code to Arduino via Arduino IDE
    通过Arduino IDE将上述代码上传到Arduino
  • Long and short press the button.
    长按和短按按钮。
  • See the result on Serial Monitor
    在串行监视器上查看结果

※ NOTE THAT: ※ 注意事项:

The Serial Monitor may show several short press detection when long press. This is the normal behavior of the button. This behavior is called the “chattering phenomenon”. The issue will be solved in the last part of this tutorial.
长按时,串行监视器可能会显示几次短按检测。这是按钮的正常行为。这种行为被称为“颤动现象”。该问题将在本教程的最后一部分解决。

Short Press and Long Press During pressing 短按和长按 按压过程中

/** Created by ArduinoGetStarted.com** This example code is in the public domain** Tutorial page: https://arduinogetstarted.com/tutorials/arduino-button-long-press-short-press*/// constants won't change. They're used here to set pin numbers:
const int BUTTON_PIN = 7; // the number of the pushbutton pin
const int SHORT_PRESS_TIME = 1000; // 1000 milliseconds
const int LONG_PRESS_TIME  = 1000; // 1000 milliseconds// Variables will change:
int lastState = LOW;  // the previous state from the input pin
int currentState;     // the current reading from the input pin
unsigned long pressedTime  = 0;
unsigned long releasedTime = 0;
bool isPressing = false;
bool isLongDetected = false;void setup() {Serial.begin(9600);pinMode(BUTTON_PIN, INPUT_PULLUP);
}void loop() {// read the state of the switch/button:currentState = digitalRead(BUTTON_PIN);if(lastState == HIGH && currentState == LOW) {        // button is pressedpressedTime = millis();isPressing = true;isLongDetected = false;} else if(lastState == LOW && currentState == HIGH) { // button is releasedisPressing = false;releasedTime = millis();long pressDuration = releasedTime - pressedTime;if( pressDuration < SHORT_PRESS_TIME )Serial.println("A short press is detected");}if(isPressing == true && isLongDetected == false) {long pressDuration = millis() - pressedTime;if( pressDuration > LONG_PRESS_TIME ) {Serial.println("A long press is detected");isLongDetected = true;}}// save the the last statelastState = currentState;
}
Quick Steps 快速步骤
  • Upload the above code to Arduino via Arduino IDE
    通过Arduino IDE将上述代码上传到Arduino
  • Long and short press the button.
    长按和短按按钮。
  • See the result on Serial Monitor
    在串行监视器上查看结果

※ NOTE THAT: ※ 注意事项:

The Serial Monitor may show several short press detection when long press. This is the normal behavior of the button. This behavior is called the “chattering phenomenon”. The issue will be solved in the last part of this tutorial.
长按时,串行监视器可能会显示几次短按检测。这是按钮的正常行为。这种行为被称为“颤动现象”。该问题将在本教程的最后一部分解决。

Long Press and Short Press with Debouncing 长按和短按带去弹跳

It is very important to debounce the button in many applications.
在许多应用中,对按钮进行去抖动非常重要。

Debouncing is a little complicated, especially when using multiple buttons. To make it much easier for beginners, we created a library, called ezButton.
去抖动有点复杂,尤其是在使用多个按钮时。为了让初学者更容易,我们创建了一个名为 ezButton 的库。

We will use this library in below codes
我们将在下面的代码中使用这个库

Short Press and Long Press with debouncing after released 短按和长按,释放后去弹跳

/** Created by ArduinoGetStarted.com** This example code is in the public domain** Tutorial page: https://arduinogetstarted.com/tutorials/arduino-button-long-press-short-press*/#include <ezButton.h>const int SHORT_PRESS_TIME = 1000; // 1000 milliseconds
const int LONG_PRESS_TIME  = 1000; // 1000 millisecondsezButton button(7);  // create ezButton object that attach to pin 7;unsigned long pressedTime  = 0;
unsigned long releasedTime = 0;void setup() {Serial.begin(9600);button.setDebounceTime(50); // set debounce time to 50 milliseconds
}void loop() {button.loop(); // MUST call the loop() function firstif(button.isPressed())pressedTime = millis();if(button.isReleased()) {releasedTime = millis();​    long pressDuration = releasedTime - pressedTime;​    if( pressDuration < SHORT_PRESS_TIME )
​      Serial.println("A short press is detected");​    if( pressDuration > LONG_PRESS_TIME )
​      Serial.println("A long press is detected");}
}
Quick Steps 快速步骤
  • Install ezButton library. See How To
    安装 ezButton 库。了解操作方法
  • Upload the above code to Arduino via Arduino IDE
    通过Arduino IDE将上述代码上传到Arduino
  • Long and short press the button.
    长按和短按按钮。
  • See the result on Serial Monitor
    在串行监视器上查看结果

Short Press and Long Press with debouncing During Pressing 短按和长按,按压过程中去弹跳

/** Created by ArduinoGetStarted.com** This example code is in the public domain** Tutorial page: https://arduinogetstarted.com/tutorials/arduino-button-long-press-short-press*/#include <ezButton.h>const int SHORT_PRESS_TIME = 1000; // 1000 milliseconds
const int LONG_PRESS_TIME  = 1000; // 1000 millisecondsezButton button(7);  // create ezButton object that attach to pin 7;unsigned long pressedTime  = 0;
unsigned long releasedTime = 0;
bool isPressing = false;
bool isLongDetected = false;void setup() {Serial.begin(9600);button.setDebounceTime(50); // set debounce time to 50 milliseconds
}void loop() {button.loop(); // MUST call the loop() function firstif(button.isPressed()){pressedTime = millis();isPressing = true;isLongDetected = false;}if(button.isReleased()) {isPressing = false;releasedTime = millis();long pressDuration = releasedTime - pressedTime;if( pressDuration < SHORT_PRESS_TIME )Serial.println("A short press is detected");}if(isPressing == true && isLongDetected == false) {long pressDuration = millis() - pressedTime;if( pressDuration > LONG_PRESS_TIME ) {Serial.println("A long press is detected");isLongDetected = true;}}
}
Quick Steps 快速步骤
  • Install ezButton library. See How To
    安装 ezButton 库。了解操作方法
  • Upload the above code to Arduino via Arduino IDE
    通过Arduino IDE将上述代码上传到Arduino
  • Long and short press the button.
    长按和短按按钮。
  • See the result on Serial Monitor
    在串行监视器上查看结果

Video Tutorial 视频教程

We are considering to make the video tutorials. If you think the video tutorials are essential, please subscribe to our YouTube channel to give us motivation for making the videos.
我们正在考虑制作视频教程。如果您认为视频教程是必不可少的,请订阅我们的 YouTube 频道,为我们制作视频提供动力。

Why Needs Long Press and Short Press 为什么需要长按和短按

  • To save the number of buttons. A single button can keep two or more functionalities. For example, short press for changing operation mode, long press for turn off the device.
    保存按钮数量。一个按钮可以保留两个或多个功能。例如,短按可更改操作模式,长按可关闭设备。
  • Use of long press to reduce the short press by accident. For example, some kinds of devices use the button for factory reset. If the button is pressed by accident, it is dangerous. To avoid it, the device is implemented to be factory reset only when the button is long-press (e.g over 5 seconds)
    使用长按减少意外短按。例如,有些设备使用按钮进行出厂重置。如果意外按下按钮,就会造成危险。为了避免这种情况,设备只有在长按按钮(例如超过 5 秒)时才能进行出厂重置。

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/diannao/35875.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

重大进展!微信支付收款码全场景接入银联网络

据中国银联6月19日消息&#xff0c;近日&#xff0c;银联网络迎来微信支付收款码场景的全面接入&#xff0c;推动条码支付互联互通取得新进展&#xff0c;为境内外广大消费者提供更多支付选择、更好支付体验。 2024年6月&#xff0c;伴随微信支付经营收款码的开放&#xff0c;微…

Docker部署Nginx+Keepalived

# 创建挂载路径 mkdir /data/nginx_keep/nginx/conf -p mkdir /data/nginx_keep/keepalived/vim nginx.conf user nginx; worker_processes auto;error_log /var/log/nginx/error.log notice; pid /var/run/nginx.pid;events {worker_connections 1024; }http {incl…

Rust: duckdb和polars读csv文件比较

一、文件准备 样本内容&#xff0c;N行9列的csv标准格式&#xff0c;有字符串&#xff0c;有浮点数&#xff0c;有整型。 有两个csv文件&#xff0c;一个大约是2.1万行&#xff1b;一个是64万行。 二、toml文件 [package] name "my_duckdb" version "0.1.0&…

opencv简单小项目

OpenCV&#xff08;Open Source Computer Vision Library&#xff09;是一个开源的计算机视觉和机器学习软件库&#xff0c;它提供了大量的图像和视频处理功能。使用OpenCV可以开发各种简单的小项目&#xff0c;例如&#xff1a; 图像基本操作&#xff1a; 读取和显示图像。调整…

弱监督学习

弱监督学习&#xff08;Weak Supervision&#xff09;是一种利用不完全、不精确或噪声数据进行模型训练的方法。以下是一些常用的弱监督方法及其原理&#xff1a; 1. 数据增强&#xff08;Data Augmentation&#xff09; 原理&#xff1a; 数据增强是一种通过增加训练数据的多…

区块链的历史和发展:从比特币到以太坊

想象一下&#xff0c;你住在一个小镇上&#xff0c;每个人都有一个大账本&#xff0c;记录着所有的交易。这个账本很神奇&#xff0c;每当有人买卖东西&#xff0c;大家都会在自己的账本上记一笔&#xff0c;确保每个人的账本都是一致的。这就是区块链的基本思想。而区块链的故…

HG/T 5838-2021金属骨架发泡橡胶复合密封板检测

金属骨架发泡橡胶复合密封板是指工作温度范围-40&#xff5e;140℃&#xff0c;峰值温度为150℃条件下使用的金属骨架发泡密封板。 HG/T 5838-2021金属骨架发泡橡胶复合密封板检测项目&#xff1a; 测试项目 测试标准 外观 HG/T 5838 厚度 HG/T 5838 压缩性能 GB/T 206…

VSCode安装OpenImageDebugger

VSCode安装OpenImageDebugger 1. 官网2. 编译2.1 依赖项2.2 编译 OpenImageDebugger2.3 配置 GDB 和 LLDB 3. 验证安装是否成功 1. 官网 下载路径&#xff1a;OpenImageDebugger 2. 编译 2.1 依赖项 官网上描述&#xff0c; Qt 5.15.1Python 3.10.12 这两个其实配置并不需…

【好物推荐】给大家安利一个liux运维全能脚本工具箱

前几天在开源社区冲浪的时候无意间逛到一个部署帖&#xff0c;里面提到了一个脚本&#xff0c;让我眼前一亮。 科技Lion的Shell脚本&#xff01;大家赶紧去体验学习一下&#xff0c;感觉写的还是不错的。 该工具是一款全能脚本工具箱&#xff0c;使用shell脚本编写。专为Linux服…

Jenkins多stage共享同一变量方式

在第一个stage中为这个变量赋值&#xff0c;在其它stage中使用这个变量 import java.nio.file.Files import java.nio.file.Path import java.nio.file.Paths import java.nio.file.StandardCopyOption import groovy.json.JsonOutput import groovy.json.JsonSlurper// 共享的…

图解HTTP笔记整理(前六章)

图解HTTP 第一章 web使用HTTP &#xff08;HyperText Transfer Protocol&#xff0c;超文本传输协议&#xff09;协议作文规范&#xff0c;完成从客户端到服务器端等一系列运作流程。 协议&#xff1a;计算机与网络设备要相互通信&#xff0c;双方就必须基于相同的方法。比如…

【论文阅读】--Popup-Plots: Warping Temporal Data Visualization

弹出图&#xff1a;扭曲时态数据可视化 摘要1 引言2 相关工作3 弹出图3.1 椭球模型3.1.1 水平轨迹3.1.2 垂直轨迹3.1.3 组合轨迹 3.2 视觉映射与交互 4 实施5 结果6 评估7 讨论8 结论和未来工作致谢参考文献 期刊: IEEE Trans. Vis. Comput. Graph.&#xff08;发表日期: 2019&…

【TS】Typescript 中,什么是函数重载

在JavaScript中&#xff0c;传统上并没有直接支持函数重载&#xff08;Function Overloading&#xff09;的概念&#xff0c;这是许多其他面向对象编程语言&#xff08;如Java、C#、C等&#xff09;的一个特性。函数重载意味着可以使用相同的函数名但不同的参数列表&#xff08…

1.3.数据的表示

定点数 原码 最高位是符号位&#xff0c;0表示正号&#xff0c;1表示负号&#xff0c;其余的n-1位表示数值的绝对值。 数值0的原码表示有两种形式&#xff1a; [0]原0 0000000 [-0]原1 0000000 例&#xff1a;1010 最高位为1表示这是一个负数&#xff0c; 其它三位 010…

HQChart使用教程30-K线图如何对接第3方数据41-分钟K线叠加股票增量更新

HQChart使用教程30-K线图如何对接第3方数据40-日K叠加股票增量更新 叠加股票叠加分钟K线更新Request 字段说明Data.symbol 协议截图返回json数据结构overlaydata HQChart代码地址交流 叠加股票 示例地址:https://jones2000.github.io/HQChart/webhqchart.demo/samples/kline_i…

可以一键生成热点营销视频的工具,建议收藏

在当今的商业环境中&#xff0c;热点营销已经成为了一种非常重要的营销策略。那么&#xff0c;什么是热点营销呢&#xff1f;又怎么做热点营销视频呢&#xff1f; 最近高考成绩慢慢公布了&#xff0c;领导让结合“高考成绩公布”这个热点&#xff0c;做一个关于企业或产品的营销…

运用 Offer 管理来提高候选人感受的关键点

一些公司不遗余力地为应聘者提供一流的感受&#xff0c;通过建立个性化的求职网站、简单的处理流程和合作的面试流程。然而&#xff0c;由于Offer管理缓慢笨拙&#xff0c;所有这些好工作都可能失败。 如果申请人想等几天才能得到你的录取通知书&#xff0c;而你的录取通知书必…

鸿蒙NEXT开发:工具常用命令—install

安装三方库。 命令格式 ohpm install [options] [[<group>/]<pkg>[<version> | tag:<tag>]] ... ohpm install [options] <folder> ohpm install [options] <har file> alias: i 说明 group&#xff1a;三方库的命名空间&#xff0c;可…

sys.stdin对象——实现标准输入

自学python如何成为大佬(目录):https://blog.csdn.net/weixin_67859959/article/details/139049996?spm1001.2014.3001.5501 语法参考 sys.stdin是一个标准化输入对象&#xff0c;可以连续输入或读入文件所有内容&#xff0c;不结束&#xff0c;不能直接使用。输入完成后&am…

print()函数——打印输出

自学python如何成为大佬(目录):https://blog.csdn.net/weixin_67859959/article/details/139049996?spm1001.2014.3001.5501 print()函数是Python编程最常见的函数&#xff0c;常用于输出程序结果&#xff0c;默认输出到屏幕&#xff0c;也可以输出到指定文件。 语法参考 pr…