diff --git a/translated/tech/20230315.0 ⭐️ Input Function in Python Concepts and Examples.md b/published/20230315.0 ⭐️ Input Function in Python Concepts and Examples.md similarity index 62% rename from translated/tech/20230315.0 ⭐️ Input Function in Python Concepts and Examples.md rename to published/20230315.0 ⭐️ Input Function in Python Concepts and Examples.md index a074a3bc0f..fe8170a65a 100644 --- a/translated/tech/20230315.0 ⭐️ Input Function in Python Concepts and Examples.md +++ b/published/20230315.0 ⭐️ Input Function in Python Concepts and Examples.md @@ -3,30 +3,30 @@ [#]: author: "Arindam https://www.debugpoint.com/author/admin1/" [#]: collector: "lkxed" [#]: translator: "geekpi" -[#]: reviewer: " " -[#]: publisher: " " -[#]: url: " " +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-15660-1.html" Python 中的输入函数:概念和示例 ====== -**在这篇文章中,我将通过一些通俗易懂的例子来解释 Python 的 Input 函数的基础知识。** +> 在这篇文章中,我将通过一些通俗易懂的例子来解释 Python 的 Input 函数的基础知识。 ![][1] -Python 是世界上最流行的编程语言之一,广泛应用于各种应用程序中。Python 中的一个基本概念是 `Input()` 函数,它允许用户通过提供输入值与程序进行交互。 +Python 是世界上最流行的编程语言之一,广泛应用于各种应用程序中。Python 中的一个基本概念是 `input()` 函数,它允许用户通过提供输入值与程序进行交互。 -让我们看看 input 函数它是如何工作的,以及如何在 Python 程序中有效地使用它。 +让我们看看 `input()` 函数是如何工作的,以及如何在 Python 程序中有效地使用它。 在开始之前,我希望你已经安装了 Python 并设置了一个基本的编辑器。如果没有,请参考我的以下指南: -- [如何在 Ubuntu/Linux 上安装 Python 3.11][2] +- [如何在 Ubuntu 等 Linux 上安装 Python 3.11][2] - [如何在 Windows 上安装 Python][3] - [如何为 Python 设置 IDLE 编辑器][4] ### Python Input 函数 -Python 中的 input 函数用于接受用户输入的字符串。它提示用户输入一个值并等待用户提供输入。然后将用户的输入作为字符串存储在变量中,稍后可以在程序中使用。 +Python 中的 `input()` 函数用于接受用户输入的字符串。它提示用户输入一个值并等待用户提供输入。然后将用户的输入作为字符串存储在变量中,稍后可以在程序中使用。 #### 句法 @@ -34,21 +34,20 @@ Python 中的 input 函数用于接受用户输入的字符串。它提示用户 input("your message to user") ``` -当你运行 input 函数时,它会向用户显示消息并_等待_输入。光标等待。当用户输入并按下回车键,input 函数就会读取用户的输入。该值存储在你指定的变量中。 +当你运行 `input()` 函数时,它会向用户显示消息并 _等待_ 输入。显示光标等待。当用户输入并按下回车键,`input()` 函数就会读取用户的输入。该值存储在你指定的变量中。 让我们看几个例子。 -### 示例 1:简单的 input 函数用法 - -以下代码片段接受输入并显示带有附加字符串的输出。 +### 示例 1:简单的 input() 函数用法 +以下代码片段接受输入并显示带有附加字符串的输出: ``` your_name = input("Enter your name:") print("Hello " + your_name) ``` -**输出:** +输出: ``` Enter your name:arindamHello arindam @@ -58,7 +57,7 @@ Enter your name:arindamHello arindam ### 示例 2:以整数和浮点数作为输入 -在使用 input() 函数时,你还可以在运行时将输入转换为 int() 或 float() 。这是一个例子。 +在使用 `input()` 函数时,你还可以在运行时使用 `int()` 或 `float()` 将输入转换。这是一个例子: ``` no_of_books = int(input("Enter total books ordered:")) @@ -79,7 +78,7 @@ Total price: 50.5 ### 示例 3:连接列表 -你还可以使用其他函数(例如列表)来接受一组值并将它们转换为 Python 中的 [list][6]。这是一个接受输入并将其转换为列表的示例。然后使用另一组值并附加到第一个列表。 +你还可以使用其他函数(例如列表)来接受一组值并将它们转换为 Python 中的 [列表][6]。这是一个接受输入并将其转换为列表的示例。然后使用另一组值并附加到第一个列表: ``` # 获取第一个列表的输入 @@ -96,7 +95,7 @@ for j in list_2: print(list_1) ``` -**输出:** +输出: ``` Enter numbers for list 1:1234 @@ -106,7 +105,7 @@ Enter some letters for list 2:ABCD ### 总结 -我希望这个简单的指南通过几个示例阐明了 input() 函数。对于简单的场景,它是一个强大的功能,可以从标准输入中接受值。 +我希望这个简单的指南通过几个示例阐明了 `input()` 函数。对于简单的场景,它是一个强大的功能,可以从标准输入中接受值。 -------------------------------------------------------------------------------- @@ -115,15 +114,15 @@ via: https://www.debugpoint.com/input-function-python/ 作者:[Arindam][a] 选题:[lkxed][b] 译者:[geekpi](https://github.com/geekpi) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 [a]: https://www.debugpoint.com/author/admin1/ [b]: https://github.com/lkxed/ [1]: https://www.debugpoint.com/wp-content/uploads/2023/03/pyinput.jpg -[2]: https://www.debugpoint.com/install-python-3-11-ubuntu/ -[3]: https://www.debugpoint.com/install-python-windows/ -[4]: https://www.debugpoint.com/install-idle-ubuntu-linux/ +[2]: https://linux.cn/article-15230-1.html +[3]: https://linux.cn/article-15480-1.html +[4]: https://linux.cn/article-15622-1.html [5]: https://www.debugpoint.com/wp-content/uploads/2023/03/Python-Input-function-a-simple-example.jpg [6]: https://docs.python.org/3/library/stdtypes.html?highlight=list#lists \ No newline at end of file