我的股票程序输入如下
'Sqin.txt' 数据读入,是一个 cvs 文件
AAC,D,20111207,9.83,9.83,9.83,9.83,100
AACC,D,20111207,3.46,3.47,3.4,3.4,13400
AACOW,D,20111207,0.3,0.3,0.3,0.3,500
AAME,D,20111207,1.99,1.99,1.95,1.99,8600
AAON,D,20111207,21.62,21.9,21.32,21.49,93200
AAPL,D,20111207,389.93,390.94,386.76,389.09,10892800
AATI,D,20111207,5.75,5.75,5.73,5.75,797900
输出是
dat1[]
['AAC', ['9.83', '9.83', '9.83', '9.83', '100'], ['9.83', '9.83', '9.83', '9.83', '100']]
dat1[0] 是用于查找和数据更新的股票代码“ACC” Dat1[1....?] 是 EOD(日终)数据 在股票市场收盘时,EOD 数据将插入 dat1。在每个更新周期插入 (1,M)。伙计们,你可以用一行代码把它写出来。到目前为止,我的代码超过 30 行,所以看我的代码是不相关的。以上是一些简单输入和所需输出的示例。
如果您决定进行一些现实世界的编程,请保持详细。声明你的变量,然后填充它,最后使用它们。
M = []
M = q [0][3:] ## had to do it this way because 'ACC' made the variable M [] begin as a string (inmutable). So I could not add M to the data.-dat1[]- because -dat1[]- also became a string (inmutable strings how stupid). Had to force 'ACC' to be a list so I can create a list of lists -dat1-
Dat1.insert(1.M) ## -M- is used to add another list to the master.dat record
也许有点像pythonic和少一点冗长就可以了。