-4

When I input the variable a

a = int(1388620800)*1000

(of course) this variable is returned

1388620800000

But in the Google Appengine Server, this variable is changed by https://cloud.google.com/appengine/docs/python/datastore/typesandpropertyclasses#int

1388620800000L

How to convert 1388620800000L to int type in Appengine?

EDIT

I will print this number for JSON. In the local Python2.7, the variable 'a' is just integer. But in the appengine server, the variable 'a' has string 'L'. I solved it using str() and .replace('L',''), but I wonder how to solve it with changing number type.

KyungHoon Kim
  • 2,859
  • 2
  • 23
  • 26

2 Answers2

0

This is not an App Engine question.

In Python, longs and ints are exactly equivalent and there is no reason you would ever need to convert from one to another.

Edit

Your explanation does not make sense either, unfortunately. JSON has no long type, and the Python json library makes no distinction between longs and ints:

>>> json.dumps(1388620800000L)
'1388620800000'
>>> json.dumps(1388620800000)
'1388620800000'

As you can see, they are treated exactly the same.

Daniel Roseman
  • 588,541
  • 66
  • 880
  • 895
0

App Engine uses python 2.7, int and long are unified in this version.

See this question for more informations: How does Python manage int and long?

I don't really get why you want to convert this number when you have in my opinion no reason to do so.

Community
  • 1
  • 1
Anhuin
  • 421
  • 3
  • 10