[英]How do I get multiple inputs from UI?
到目前為止,這是我的代碼
def sbc(): #splits up dataframe by account
accounts = []
acc = raw_input("Enter account abbreviations one at a time. Enter 'end' to load media lists.")
frame = rlf()
while True:
if acc == 'end':
break
else:
accounts.append(acc)
for ac in accounts:
frame = frame[frame['Campaign'].str.startswith(ac)]
path = r'C:\\Users\\CP\\Documents\\Python_WL\\'+str(ac)+str(time.strftime("%d.%m.%Y"))+'.xls'
if len(frame) > 50:
frame.to_excel(path)
我希望能夠在“帳戶”中有多個條目,但是,當我運行該程序時,它只允許我輸入一個值。 我很困惑,因為另一部分代碼確實按照我希望的方式重復,以“說明”該代碼為:
def rlf(): #removes low fill rate
frame = rbs()
inputted_fill_rate = raw_input("Fill Rate cutoff? (Format: 0.nn): ")
return frame[frame['Fill Rate'] >= float(inputted_fill_rate)]
將raw_input
調用移到循環內部。 您可能還想取消縮進for
循環。
def sbc(): #splits up dataframe by spotx account
accounts = []
frame = rlf()
while True:
acc = raw_input("Enter account abbreviations one at a time. Enter 'end' to load media lists.")
if acc == 'end':
break
else:
accounts.append(acc)
for ac in accounts:
frame = frame[frame['Campaign'].str.startswith(ac)]
path = r'C:\\Users\\CP\\Documents\\Python_WL\\'+str(ac)+str(time.strftime("%d.%m.%Y"))+'.xls'
if len(frame) > 50:
frame.to_excel(path)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.