Extract values from dict [closed]Calling a function of a module by using its name (a string)How to merge two dictionaries in a single expression?Sort a Map<Key, Value> by valuesHow to return multiple values from a function?How to print without newline or space?Convert bytes to a string?How do I sort a dictionary by value?Why can't Python parse this JSON data?Extract file name from path, no matter what the os/path formatWhy is “1000000000000000 in range(1000000000000001)” so fast in Python 3?
Do people actually use the word "kaputt" in conversation?
Is this saw blade faulty?
Why can't I get pgrep output right to variable on bash script?
Center page as a whole without centering each element individually
Did I make a mistake by ccing email to boss to others?
Why is "la Gestapo" feminine?
Is there any common country to visit for persons holding UK and Schengen visas?
Error in master's thesis, I do not know what to do
Not hide and seek
Started in 1987 vs. Starting in 1987
What do the positive and negative (+/-) transmit and receive pins mean on Ethernet cables?
Toggle window scroll bar
1 John in Luther’s Bibel
If the Dominion rule using their Jem'Hadar troops, why is their life expectancy so low?
Checking @@ROWCOUNT failing
New Order #2: Turn My Way
Why doesn't Gödel's incompleteness theorem apply to false statements?
Trouble reading roman numeral notation with flats
Calculate Pi using Monte Carlo
Exposing a company lying about themselves in a tightly knit industry (videogames) : Is my career at risk on the long run?
Put the phone down / Put down the phone
Travelling in US for more than 90 days
When is the exact date for EOL of Ubuntu 14.04 LTS?
Do native speakers use "ultima" and "proxima" frequently in spoken English?
Extract values from dict [closed]
Calling a function of a module by using its name (a string)How to merge two dictionaries in a single expression?Sort a Map<Key, Value> by valuesHow to return multiple values from a function?How to print without newline or space?Convert bytes to a string?How do I sort a dictionary by value?Why can't Python parse this JSON data?Extract file name from path, no matter what the os/path formatWhy is “1000000000000000 in range(1000000000000001)” so fast in Python 3?
I have a problem that is to extract all values from two dictionaries:
'Art': ['SKU': 'BS0000504000', 'SKU': 'BS0000504010', 'SKU': 'BS0000504500', 'SKU': 'BS0000505000',....]
How I can extract all values of SKU dynamical?
Another example that I like to know what is the best approach to extract values.
'Art1': 'SKU': 'BS0000504000', 'Art2': 'SKU': 'BS000050401', 'Art3': 'SKU': 'BS0000504500', 'Art4': 'SKU': 'BS0000505000',....]
In this case I use this print(result['Art1']['SKU']) to extract the SKU from Art1, but I like to extract all value from Art1, Art2, ..., Artn.
Thanks
python json python-3.x dictionary
closed as off-topic by js1568, xlm, TofuBeer, Sid S, Alexandre Dion Mar 7 at 22:42
This question appears to be off-topic. The users who voted to close gave this specific reason:
- "Questions seeking debugging help ("why isn't this code working?") must include the desired behavior, a specific problem or error and the shortest code necessary to reproduce it in the question itself. Questions without a clear problem statement are not useful to other readers. See: How to create a Minimal, Complete, and Verifiable example." – js1568, xlm, Sid S, Alexandre Dion
add a comment |
I have a problem that is to extract all values from two dictionaries:
'Art': ['SKU': 'BS0000504000', 'SKU': 'BS0000504010', 'SKU': 'BS0000504500', 'SKU': 'BS0000505000',....]
How I can extract all values of SKU dynamical?
Another example that I like to know what is the best approach to extract values.
'Art1': 'SKU': 'BS0000504000', 'Art2': 'SKU': 'BS000050401', 'Art3': 'SKU': 'BS0000504500', 'Art4': 'SKU': 'BS0000505000',....]
In this case I use this print(result['Art1']['SKU']) to extract the SKU from Art1, but I like to extract all value from Art1, Art2, ..., Artn.
Thanks
python json python-3.x dictionary
closed as off-topic by js1568, xlm, TofuBeer, Sid S, Alexandre Dion Mar 7 at 22:42
This question appears to be off-topic. The users who voted to close gave this specific reason:
- "Questions seeking debugging help ("why isn't this code working?") must include the desired behavior, a specific problem or error and the shortest code necessary to reproduce it in the question itself. Questions without a clear problem statement are not useful to other readers. See: How to create a Minimal, Complete, and Verifiable example." – js1568, xlm, Sid S, Alexandre Dion
Hey there, I can see that you're new to Stack Overflow. Might you have any code samples for what you've tried so far, perhaps using aforloop or aforEach?
– Hannele
Mar 7 at 20:05
add a comment |
I have a problem that is to extract all values from two dictionaries:
'Art': ['SKU': 'BS0000504000', 'SKU': 'BS0000504010', 'SKU': 'BS0000504500', 'SKU': 'BS0000505000',....]
How I can extract all values of SKU dynamical?
Another example that I like to know what is the best approach to extract values.
'Art1': 'SKU': 'BS0000504000', 'Art2': 'SKU': 'BS000050401', 'Art3': 'SKU': 'BS0000504500', 'Art4': 'SKU': 'BS0000505000',....]
In this case I use this print(result['Art1']['SKU']) to extract the SKU from Art1, but I like to extract all value from Art1, Art2, ..., Artn.
Thanks
python json python-3.x dictionary
I have a problem that is to extract all values from two dictionaries:
'Art': ['SKU': 'BS0000504000', 'SKU': 'BS0000504010', 'SKU': 'BS0000504500', 'SKU': 'BS0000505000',....]
How I can extract all values of SKU dynamical?
Another example that I like to know what is the best approach to extract values.
'Art1': 'SKU': 'BS0000504000', 'Art2': 'SKU': 'BS000050401', 'Art3': 'SKU': 'BS0000504500', 'Art4': 'SKU': 'BS0000505000',....]
In this case I use this print(result['Art1']['SKU']) to extract the SKU from Art1, but I like to extract all value from Art1, Art2, ..., Artn.
Thanks
python json python-3.x dictionary
python json python-3.x dictionary
edited Mar 7 at 0:54
blhsing
39.4k41743
39.4k41743
asked Mar 7 at 0:47
Andre SantosAndre Santos
42
42
closed as off-topic by js1568, xlm, TofuBeer, Sid S, Alexandre Dion Mar 7 at 22:42
This question appears to be off-topic. The users who voted to close gave this specific reason:
- "Questions seeking debugging help ("why isn't this code working?") must include the desired behavior, a specific problem or error and the shortest code necessary to reproduce it in the question itself. Questions without a clear problem statement are not useful to other readers. See: How to create a Minimal, Complete, and Verifiable example." – js1568, xlm, Sid S, Alexandre Dion
closed as off-topic by js1568, xlm, TofuBeer, Sid S, Alexandre Dion Mar 7 at 22:42
This question appears to be off-topic. The users who voted to close gave this specific reason:
- "Questions seeking debugging help ("why isn't this code working?") must include the desired behavior, a specific problem or error and the shortest code necessary to reproduce it in the question itself. Questions without a clear problem statement are not useful to other readers. See: How to create a Minimal, Complete, and Verifiable example." – js1568, xlm, Sid S, Alexandre Dion
Hey there, I can see that you're new to Stack Overflow. Might you have any code samples for what you've tried so far, perhaps using aforloop or aforEach?
– Hannele
Mar 7 at 20:05
add a comment |
Hey there, I can see that you're new to Stack Overflow. Might you have any code samples for what you've tried so far, perhaps using aforloop or aforEach?
– Hannele
Mar 7 at 20:05
Hey there, I can see that you're new to Stack Overflow. Might you have any code samples for what you've tried so far, perhaps using a
for loop or a forEach?– Hannele
Mar 7 at 20:05
Hey there, I can see that you're new to Stack Overflow. Might you have any code samples for what you've tried so far, perhaps using a
for loop or a forEach?– Hannele
Mar 7 at 20:05
add a comment |
1 Answer
1
active
oldest
votes
Assuming your dict is stored as variable d, the following list comprehension will extract the SKU values in the first format:
[s['SKU'] for l in d.values() for s in l]
and the following list comprehension will extract the SKU values in the second format:
[s['SKU'] for s in d.values()]
I have something like this?... import requests import time url = "siteurl.test" data = requests.get(url) d = data.json() t0 = time.time() [s['SKU'] for s in d.values()] print("Total time " + str(time.time() - t0) + " sec")
– Andre Santos
Mar 7 at 1:05
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Assuming your dict is stored as variable d, the following list comprehension will extract the SKU values in the first format:
[s['SKU'] for l in d.values() for s in l]
and the following list comprehension will extract the SKU values in the second format:
[s['SKU'] for s in d.values()]
I have something like this?... import requests import time url = "siteurl.test" data = requests.get(url) d = data.json() t0 = time.time() [s['SKU'] for s in d.values()] print("Total time " + str(time.time() - t0) + " sec")
– Andre Santos
Mar 7 at 1:05
add a comment |
Assuming your dict is stored as variable d, the following list comprehension will extract the SKU values in the first format:
[s['SKU'] for l in d.values() for s in l]
and the following list comprehension will extract the SKU values in the second format:
[s['SKU'] for s in d.values()]
I have something like this?... import requests import time url = "siteurl.test" data = requests.get(url) d = data.json() t0 = time.time() [s['SKU'] for s in d.values()] print("Total time " + str(time.time() - t0) + " sec")
– Andre Santos
Mar 7 at 1:05
add a comment |
Assuming your dict is stored as variable d, the following list comprehension will extract the SKU values in the first format:
[s['SKU'] for l in d.values() for s in l]
and the following list comprehension will extract the SKU values in the second format:
[s['SKU'] for s in d.values()]
Assuming your dict is stored as variable d, the following list comprehension will extract the SKU values in the first format:
[s['SKU'] for l in d.values() for s in l]
and the following list comprehension will extract the SKU values in the second format:
[s['SKU'] for s in d.values()]
answered Mar 7 at 0:52
blhsingblhsing
39.4k41743
39.4k41743
I have something like this?... import requests import time url = "siteurl.test" data = requests.get(url) d = data.json() t0 = time.time() [s['SKU'] for s in d.values()] print("Total time " + str(time.time() - t0) + " sec")
– Andre Santos
Mar 7 at 1:05
add a comment |
I have something like this?... import requests import time url = "siteurl.test" data = requests.get(url) d = data.json() t0 = time.time() [s['SKU'] for s in d.values()] print("Total time " + str(time.time() - t0) + " sec")
– Andre Santos
Mar 7 at 1:05
I have something like this?... import requests import time url = "siteurl.test" data = requests.get(url) d = data.json() t0 = time.time() [s['SKU'] for s in d.values()] print("Total time " + str(time.time() - t0) + " sec")
– Andre Santos
Mar 7 at 1:05
I have something like this?... import requests import time url = "siteurl.test" data = requests.get(url) d = data.json() t0 = time.time() [s['SKU'] for s in d.values()] print("Total time " + str(time.time() - t0) + " sec")
– Andre Santos
Mar 7 at 1:05
add a comment |
Hey there, I can see that you're new to Stack Overflow. Might you have any code samples for what you've tried so far, perhaps using a
forloop or aforEach?– Hannele
Mar 7 at 20:05