作者ghkckhg (名字背过又忘记)
看板Python
标题[问题] 错误?
时间Wed Aug 6 19:40:18 2014
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://webptt.com/cn.aspx?n=bbs/Python/M.1407325220.A.425.html
1F:推 LiloHuang:你是用 Python with Braces 吗 XD 不然怎会有大括号出现 08/06 20:19
2F:推 flarehunter:改用dict比较好吧 08/06 21:36
3F:推 Neisseria:试了一下,你的程式可以跑,要不要把错误讯贴上来? 08/06 22:34