作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
这个问题在这里已经有了答案:
How to read an array of integers from single line of input in python3
(4 个回答)
去年关闭。
就像在 C++ 中一样,我怎样才能让用户输入达到一个范围
下面是在 C++ 中获取用户输入的代码
#include<iostream>
using namespace std;
int main() {
int array[50];
cin>>n;
//ask a list
for(i = 0; i<n; i++){
cin>>array[i];
}
}
如何在 Python 3 中询问上述用户输入? (我不想在不同的行中输入)
最佳答案
这将转换由空格分隔的数字以存储在 ar 中:
ar = list(map(int, input().strip().split(' ')))
关于python - 如何在Python的单行中将n个数字作为输入,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48841186/
我是一名优秀的程序员,十分优秀!