The current number of milliseconds since the epoch is 1395245378429
; on unix (64 bit / Ubuntu / python 2.7), you can do:
>>> t = 1395245378429
>>> type(t)
<type 'int'>
>>> t = 1395245378429L
>>> type(t)
<type 'long'>
>>> int(t)
1395245378429
>>> type(int(t)
<type 'int'>
but on Windows (also 64 bit / python 2.7), this happens:
>>> t = 1395245378429
>>> type(t)
<type 'long'>
>>> int(t)
1395245378429L
>>> type(int(t))
<type 'long'>
so, the following weird observations:
- on Windows,
int(<long>)
returns a long
- the same number is treated as a long in Windows, but an int on unix
I can't see anything obvious in the documentation to say this is correct behaviour; is there a (correct) way to convert the long to an int (i.e. so it can be used in a method which requires an int argument)
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…