#input #user-input #python #user #implementation #rust

python-input

Python 'input' 函数的 Rust 实现

4 个版本 (重大更改)

0.8.0 2020年1月13日
0.7.0 2020年1月13日
0.6.0 2020年1月13日
0.5.0 2020年1月13日

#15 in #implementation

MIT 许可证

3KB

python-input

Python 输入函数的简单纯 Rust 实现。

函数

目前只有一个函数,即 input 函数。

输入函数

输入函数接受一个参数,一个字符串,该字符串将被打印到控制台作为对用户的提示。

示例代码

将以下内容添加到您的 Cargo.toml 文件中

[dependencies]
...
python-input = "0.8.0"
...

将以下内容添加到您的 Rust 文件中

extern crate python_input;

use python_input::input;

fn main() {
  let name = input("What is your name? ");
  let age = input("How old are you? ");

  println!("Hello {}, you are {} years old.", name, age);
}

无运行时依赖项