Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

dict_values to string in python

I simply want to convert an object that looks like this:

dict_values(['baf0242b-d7fc-49d7-aada-220344969fb6'])

That I got from doing this:

dictionary.values()

To a simple string: 'baf0242b-d7fc-49d7-aada-220344969fb6'

How can I?

like image 678
Miguel Santos Avatar asked Sep 24 '26 21:09

Miguel Santos


1 Answers

Say you have a dictionary:

d = {'key': 'baf0242b-d7fc-49d7-aada-220344969fb6'}

The result you see is from running the following:

d.values()

To get what you want, convert it to a list and get the first item on it:

d = {'key': 'baf0242b-d7fc-49d7-aada-220344969fb6'}
result = list(d.values())[0]
like image 50
Eli Mintz Avatar answered Sep 26 '26 14:09

Eli Mintz