Python和阵列 [英] Python and arrays

查看:338
本文介绍了Python和阵列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道蟒蛇是一个疯狂的语言,因为它是个循环结构:)

I know that python is a crazy language because of it's cycles constructions :)

所以,我有号的数组,但字符串类型:

So, I have an array of numbers but in string type:

a = ['1', '40', '356', '...']

我需要这或本阵的副本,但浮动类型,而不是字符串。唯一的一点是,code应该在一行中。

I need this or a copy of this array but with float type instead of string. The only thing is that the code should be in one line.

请帮助我:)

推荐答案

您可以使用 地图() [文件] 并的 浮动() [文件]

You can use map()[docs] and float()[docs]:

b = map(float, a)

这篇关于Python和阵列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆