0
import csv
oneFileName = listOfFiles[0]
lineNum = 0
listOfLists = []
with open(oneFileName,"rt") as csvfile:
lineReader = csv.reader(csvfile,delimiter=",",quotechar="\"")
for row in lineReader:
lineNum = (lineNum + 1)
if lineNum == 1:
print("Skipping the header row")
continue
symbol = row[0]
close = row[5]
prevClose = row[7]
tradedQty = row[9]
pctChange = float(float(close)/float(prevClose) - 1)
oneResultRow = [symbol, pctChange,float(tradedQty)]
listOfLists.append(oneResultRow)
print(symbol, "{:,.lf}".format(float(tradedQty/1e6), "M INR", "{:,.lf}".format(pctChange*100), "%"))
print("Done iterating over the file contents - the file is closed now!")
print("We have stock info for " + str(len(listOfLists)))
listOfListsSortedByQty = sorted(listOfLists, key=lambda x:x[2], reverse=True)
listOfListsSortedByQty = sorted(listOfLists, key=lambda x: x[1], reverse=True)
我不斷收到此錯誤:1e6是否會導致類型錯誤?
print(symbol, "{:,.lf}".format(float(tradedQty/1e6), "M INR", "{:,.lf}".format(pctChange*100), "%"))
TypeError: unsupported operand type(s) for /: 'str' and 'float