I stored ip in sqlite database as normal string, but when i try to get that ip from database
>>> p = Info.objects.get(id = 1)
>>> p.ip
>>> u"[u'10.10.10.1']"`
How I can get normal string "10.10.10.1"
What you have there is a list
with just one element.
To get the element from the list you could use p.ip[0]
.
That would give you a unicode
object, then if you want to convert it to a string (just some bytes) you should use encode
, i.e. p.ip[0].encode('utf8')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With