Python Forum
type change of dbshelve key between Python 2 and 3
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
type change of dbshelve key between Python 2 and 3
#3
(Feb-01-2021, 11:49 PM)ccaudle Wrote: Does that seem reasonable? Just use encode() and decode() to go between UTF-8 strings and byte values when dealing with the key values?
Yes that's fine,Python 3 all that comes will be bytes if no encoding is specified.
>>> s = b'0x2044301'
>>> type(s)
<class 'bytes'>
>>> s = s.decode() # Same as s.decode('utf-8')
>>> s
'0x2044301'
>>> type(s)
<class 'str'> 
Any advice, or any known resources that have good advice on choosing a small db engine?
TinyDB, dataset
My test of dataset.
Reply


Messages In This Thread
RE: type change of dbshelve key between Python 2 and 3 - by snippsat - Feb-02-2021, 12:40 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
Question dict value, how to change type from int to list? swissjoker 3 2,813 Dec-09-2020, 09:50 AM
Last Post: perfringo
  Python - change variable type during program execution ple 1 2,438 Apr-12-2020, 08:43 AM
Last Post: buran
  Type hinting - return type based on parameter micseydel 2 2,550 Jan-14-2020, 01:20 AM
Last Post: micseydel
  Change Column Type Talch 0 2,145 Aug-16-2018, 03:02 PM
Last Post: Talch
  Change type of elements in a list by column tkj80 7 6,952 Jan-04-2017, 11:15 PM
Last Post: tkj80

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020