iT邦幫忙

0

python 要怎麼連續取得多個變數

在c#語法中
cout<<"請輸入 a1 \n a2 \n a3 \n"
cin>>a1,a2,a3
即可連續取得多筆資料
在python 中 input("請輸入a1,a2,a3") 只會輸入一個資料
還有python還有其他取得資料的方法嗎

小魚 iT邦大師 1 級 ‧ 2019-07-26 07:41:13 檢舉
題外話,
那是C++,
不是C#...
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中
2
dragonH
iT邦超人 5 級 ‧ 2019-07-25 22:50:01

其中一種

myInputs = input('請輸入a1,a2,a3\n')
for myinput in myInputs.split(','):
  print(myinput.strip())

1
黃彥儒
iT邦高手 1 級 ‧ 2019-07-26 01:02:51
a = list()
a.append(input("請輸入變數"))
while True:
    b = input()
    if b == "":
        break
    else:
        a.append(b)
0
oddtea
iT邦見習生 ‧ 2022-10-22 09:43:21
a,b=map(int,input().split())

需要多少前面就用多少
int那可更改為需要的屬性

我要發表回答

立即登入回答