【发布时间】:2018-10-04 14:56:24
【问题描述】:
我想创建一个这样的整数数组 (15,0,15,47,0,15,15,0,0,15,0,0,17,0,14,0,0,15 ,0,0,22,29,0,0,29,22,15,15,0,15,15,0,16,0,0,16,0,0,0,0,17,0,0 ,19,21,0,17,16,15,0,16,0,0,15,0,16,0,0,0,15,0,16,16,0,0,0,14,21 ,14,21,14,0,14,29,0,14,15,15,16,0,0,0,29,22,0,0,0,0,14,0,0,0,15 ,0,15,16,0,0,31,14,0,0,0,0,13,13,0,0,0,14,20,27,0,0,0,0,0,15 ,29,15,0,0,0,0,21,28,0,15,15,16,0,0,0,0,0,15,0,0,0,15,0,15,0 ,0,0,17,0,0,0,0,18,0,0,15,0,0,0,15,15,0,0,15,15,0,0,0,30,16 ,0,0,14,27,14,0,0,14,14,14,14,21,14,29,0,0,0,14,14,0,0,45,16,0,0 ,29,15,0,0,0,0,15,0,17,0,0,13,13,0,13,27,28,0,13,0,13,13,40,0,0 ,13,0,0,0,26,13,0,19,25,13,12,25,31,0,13,13,0,0,13,14,13,0,13,0,0 ,0,12,19,13,26,0,13,13,0,27,15,14,0,13,0,50,13,100) 在 Python 中......
我试过了:
data = int(x,x,x,x,x,...etc)
我有这个错误: TypeError: int() 最多接受 2 个参数(给定 254 个)
这怎么可能?我正在使用 Python 3.7 开发 Jupyter
提前谢谢你!
【问题讨论】:
-
使用列表运算符
[],[5,0,15,47,0,15,15,0,0,15,0,0,17,0,14,0,0,15,0,0,22,29,0,0,2...] -
好吧,我也试过了,但后来我必须以这种方式修改数据:Data = [[[(data+j)/100] for data in range(5)]for j in data ] 我收到此错误:TypeError: unsupported operand type(s) for /: 'list' and 'int' .... 我如何获得可以在第二步中修改的整数列表?对不起,我知道我的解释不太好
-
最好先了解一下
lists(可能还有介绍性教程的其余部分),然后再继续。
标签: python arrays jupyter-notebook