python的六大数据类型中可以改变_在python中更改数组的数据类型
我通過生成一組隨機數并將它們轉換為int類型來創建數組。但是,我不認為我下面的方法是有效的。有沒有最好的方法來改變數組中的數據類型?# standard normal distributed random numbers
c=random.randn(5,5)
c
array([[-0.37644781, -0.81347483, -0.36895952, -2.68702544, -0.96780752],
[ 0.05293328, 1.65260753, 0.55586611, -0.5786392 , 0.50865003],
[ 1.25508358, 0.51783276, 2.36435212, -0.23484705, -1.20999296],
[ 2.07552172, 0.65506648, 0.10231436, -0.26046045, 0.40148111],
[ 0.24864496, -1.8852587 , -2.51091886, 1.01106003, 1.53118353]])
d=array([[-0.37644781, -0.81347483, -0.36895952, -2.68702544, -0.96780752],
[ 0.05293328, 1.65260753, 0.55586611, -0.5786392 , 0.50865003],
[ 1.25508358, 0.51783276, 2.36435212, -0.23484705, -1.20999296],
[ 2.07552172, 0.65506648, 0.10231436, -0.26046045, 0.40148111],
[ 0.24864496, -1.8852587 , -2.51091886, 1.01106003, 1.53118353]],dtype=int)
d
array([[ 0, 0, 0, -2, 0],
[ 0, 1, 0, 0, 0],
[ 1, 0, 2, 0, -1],
[ 2, 0, 0, 0, 0],
[ 0, -1, -2, 1, 1]])
總結
以上是生活随笔為你收集整理的python的六大数据类型中可以改变_在python中更改数组的数据类型的全部內容,希望文章能夠幫你解決所遇到的問題。
                            
                        - 上一篇: 怎样配oracle环境,oracle配置
 - 下一篇: unity 检测文本有没有自动换行_py