将多行输入存储到String(Python)中
发布时间:2020-12-20 12:42:29 所属栏目:Python 来源:网络整理
导读:输入: 359716482867345912413928675398574126546281739172639548984163257621857394735492861 我的代码: print("Enter the array:n") userInput = input().splitlines()print(userInput) 我的问题是,userInput只接受第一行值,但它没有 似乎在第一行之后接
输入:
359716482 867345912 413928675 398574126 546281739 172639548 984163257 621857394 735492861 我的代码: print("Enter the array:n") userInput = input().splitlines() print(userInput) 我的问题是,userInput只接受第一行值,但它没有 解决方法
您可以使用文件对象的readlines()方法:
import sys userInput = sys.stdin.readlines() (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |