Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Avoid L suffix for Long in python [duplicate]

I have a dictionary which may have long values for some key. I want to convert this dictionary to string and send it to a server. But when I am converting it to a string using str(dict) function for the values which have a long value is suffixed with 'L'. This when I am sending it to a server the value it is generating a problem. So can anyone suggest me a easier way of what I can do to avoid the 'L' suffix

like image 968
Shrikanth Kalluraya Avatar asked Dec 17 '25 17:12

Shrikanth Kalluraya


1 Answers

I'm not sure what your use case is but to solve this problem and quite possibly the next problem you'll have I'd suggest using json.

import json
a = {'a': 10, 'b': 1234567812345678L}
print json.dumps(a)

# output:
{"a": 10, "b": 1234567812345678}
like image 150
Phil Cooper Avatar answered Dec 19 '25 07:12

Phil Cooper



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!