开发者社区> 问答> 正文

请教各位,'float' object is not subscriptable?400报错

请教各位大侠,问题如下

list_001 = [9.1454247, 53.48538079999999, 9.01548, 53.16778, 9.1434819, 53.4873555, 9.1451686, 53.48564990000001, 9.14256, 53.48726, 9.1393, 53.48882, 9.145203, 53.4865261, 9.1449977, 53.4899644, 9.1448787, 53.4857361, 9.14495, 53.48965, 9.145296799999999, 53.485342, 9.1447931, 53.4865513, 9.1454247, 53.48538079999999]

for num1 in range(1, len(list_001)):
  k1 = list_001[num1][0]
  k2 = list_001[num1][1]
  print(num1)
  print(k1)
  print(k2)

运行结果报错是

  File "C:\Python_3.6\Python_File_Py\EX_001\range_print.py", line 4, in <module>
    k1 = list_001[num1][0]
TypeError: 'float' object is not subscriptable

请教大家应该怎么改正啊

展开
收起
爱吃鱼的程序员 2020-06-06 16:58:08 4296 0
1 条回答
写回答
取消 提交回答
  • https://developer.aliyun.com/profile/5yerqm5bn5yqg?spm=a2c6h.12873639.0.0.6eae304abcjaIB
                        <p>k1 = str(list_001[num])[0]</p>
    

    k2 = str(list_001[num])[1]

    但是不知道你要干嘛。。。。

    2020-06-06 16:58:25
    赞同 展开评论 打赏
问答标签:
问答地址:
问答排行榜
最热
最新

相关电子书

更多
低代码开发师(初级)实战教程 立即下载
冬季实战营第三期:MySQL数据库进阶实战 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载