问题描述:

How do I cast a float into long in Python 2.7?

I'm doing the same in Python 2.3 like this:

`from array import*`

data = array('L',[12.34])

print data

which prints out:

`array('L',[12L])`

How do I do the same in Python 2.7?

Maybe like this?

```
>>> long(12.34)
12L
```

These days, it is much more common to see `numpy`

arrays than arrays from the `array`

module, however, your array can be constructed as:

```
>>> from array import *
>>> array('L',map(long,[12.34]))
array('L', [12L])
```

with numpy, it could be done as:

```
>>> import numpy as np
>>> np.array([12.34],dtype=long)
```

However, this doesn't actually create python longs, it actually creates an array of `np.int64`

integers (8 byte ints -- Not arbitrary precision like python long).

```
lst = [1.1,2.2]
data = map(long,lst)
```