3 回答

TA貢獻(xiàn)1827條經(jīng)驗(yàn) 獲得超8個(gè)贊
一些修復(fù):
添加了列表,最后需要解壓列表。
print("Hello world")
qstn_1="What is your name?\t"
qstn_2="Where would you like to GO for vacation?\t"
polling_active=True
name_lst = []
place_lst = []
while polling_active:
name_lst.append(input(qstn_1))
place_lst.append(input(qstn_2))
other=input("Would you like other person to answer these survey questions ?\t\n")
polling_active=False
if other=='yes':
polling_active=True
print("\n\n\t\t\tPOLLING RESULTS\n")
for i_name, i_place in zip(name_lst, place_lst):
print("\n\n\t" + i_name.title() + " would like to go to " + i_place + " for a vacation!\n")

TA貢獻(xiàn)1884條經(jīng)驗(yàn) 獲得超4個(gè)贊
正則表達(dá)式:
\d+(?:\.\d+)?
代碼:
import re a = [float(s) for s in re.findall("\d+(?:\.\d+)?", a)] print (a)
輸出:
[47.2, 46.6, 46.4, 46.0, 45.7, 45.54, 45.29, 45.01, 44.79, 44.54, 44.15, 0.0]

TA貢獻(xiàn)1813條經(jīng)驗(yàn) 獲得超2個(gè)贊
.
這是因?yàn)槟谡齽t表達(dá)式中包含了要匹配的 。請(qǐng)。更改整數(shù)的正則表達(dá)式
你應(yīng)該使用(\d+(?:\.\d+)?)
而不是你的正則表達(dá)式
添加回答
舉報(bào)