[問題] 錯誤?

看板Python作者 (名字背過又忘記)時間11年前 (2014/08/06 19:40), 編輯推噓3(300)
留言3則, 3人參與, 最新討論串1/1
tt9_ltd=[ [20140731, -43924], [20140801, -46905], [20140804, -51594], [20140805, -46340], [20140806, -51764], [20140807, 10000] ] def enter_pnl(): date_list=[] for tt in tt9_ltd: {date_list.append(tt[0])} input_date=input("Please enter today's Date yyyymmdd: ") input_pnl=input("Please enter today's PnL xxxx: ") if int(input_date) in date_list: { print("Date already exists. Overwriting....") tt9_ltd.pop(date_list.index(int(input_date))) tt9_ltd.append([int(input_date),int(input_pnl)]) } else: { tt9_ltd.append([int(input_date),int(input_pnl)]) } return(tt9_ltd) // 請問黃色那兩行為何會導致錯誤/停止compiler? 新手發問,感激不盡~ -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 220.129.149.150 ※ 文章網址: http://www.ptt.cc/bbs/Python/M.1407325220.A.425.html

08/06 20:19, , 1F
你是用 Python with Braces 嗎 XD 不然怎會有大括號出現
08/06 20:19, 1F

08/06 21:36, , 2F
改用dict比較好吧
08/06 21:36, 2F

08/06 22:34, , 3F
試了一下,你的程式可以跑,要不要把錯誤訊貼上來?
08/06 22:34, 3F
文章代碼(AID): #1JuXGaGb (Python)
文章代碼(AID): #1JuXGaGb (Python)