please help, i'm using python 3.4 and i'm trying to figure out how to convert a list of string numbers into a list of string int or float so i can get mean of x and y cordinates. mycode.
filH = open('regres.dat', r')
fileL = filH.readlines()
for line in fileL:
i = line.split(",")
tl_list = (I[0],'\t',x[1])
xx_list = (tl_list[0])
yy_list = (tl_list[2])
S = (sum(xx_list)/float(len(y_list))
print(s)
I keep getting the error str to int. I tried .lstrip but is not working, as well as running it through a loop for n. could there be a faster way to strip my list of end ccommas.
似乎您正在尝试对字符串进行数学运算。
S = sum(map(float,xx_list))/len(y_list)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.