“Python créant un dict à partir d'une chaîne écrite comme un dict” Réponses codées

Python créant un dict à partir d'une chaîne écrite comme un dict

# Python3 code to demonstrate
# convert dictionary string to dictionary
# using ast.literal_eval()
import ast
  
# initializing string 
test_string = '{"Nikhil" : 1, "Akshat" : 2, "Akash" : 3}' 
  
# printing original string 
print("The original string : " + str(test_string))
  
# using ast.literal_eval()
# convert dictionary string to dictionary
res = ast.literal_eval(test_string)
  
# print result
print("The converted dictionary : " + str(res))
SuperPro Cz

Python créant un dict à partir d'une chaîne écrite comme un dict

# Python3 code to demonstrate
# convert dictionary string to dictionary
# using ast.literal_eval()
import ast
  
# initializing string 
test_string = '{"Nikhil" : 1, "Akshat" : 2, "Akash" : 3}' 
  
# printing original string 
print("The original string : " + str(test_string))
  
# using ast.literal_eval()
# convert dictionary string to dictionary
res = ast.literal_eval(test_string)
  
# print result
print("The converted dictionary : " + str(res))
SuperPro Cz

Python créant un dict à partir d'une chaîne écrite comme un dict

# Python3 code to demonstrate
# convert dictionary string to dictionary
# using ast.literal_eval()
import ast
  
# initializing string 
test_string = '{"Nikhil" : 1, "Akshat" : 2, "Akash" : 3}' 
  
# printing original string 
print("The original string : " + str(test_string))
  
# using ast.literal_eval()
# convert dictionary string to dictionary
res = ast.literal_eval(test_string)
  
# print result
print("The converted dictionary : " + str(res))
SuperPro Cz

Python créant un dict à partir d'une chaîne écrite comme un dict

# Python3 code to demonstrate
# convert dictionary string to dictionary
# using ast.literal_eval()
import ast
  
# initializing string 
test_string = '{"Nikhil" : 1, "Akshat" : 2, "Akash" : 3}' 
  
# printing original string 
print("The original string : " + str(test_string))
  
# using ast.literal_eval()
# convert dictionary string to dictionary
res = ast.literal_eval(test_string)
  
# print result
print("The converted dictionary : " + str(res))
SuperPro Cz

Python créant un dict à partir d'une chaîne écrite comme un dict

# Python3 code to demonstrate
# convert dictionary string to dictionary
# using ast.literal_eval()
import ast
  
# initializing string 
test_string = '{"Nikhil" : 1, "Akshat" : 2, "Akash" : 3}' 
  
# printing original string 
print("The original string : " + str(test_string))
  
# using ast.literal_eval()
# convert dictionary string to dictionary
res = ast.literal_eval(test_string)
  
# print result
print("The converted dictionary : " + str(res))
SuperPro Cz

Python créant un dict à partir d'une chaîne écrite comme un dict

# Python3 code to demonstrate
# convert dictionary string to dictionary
# using ast.literal_eval()
import ast
  
# initializing string 
test_string = '{"Nikhil" : 1, "Akshat" : 2, "Akash" : 3}' 
  
# printing original string 
print("The original string : " + str(test_string))
  
# using ast.literal_eval()
# convert dictionary string to dictionary
res = ast.literal_eval(test_string)
  
# print result
print("The converted dictionary : " + str(res))
SuperPro Cz

Python créant un dict à partir d'une chaîne écrite comme un dict

# Python3 code to demonstrate
# convert dictionary string to dictionary
# using ast.literal_eval()
import ast
  
# initializing string 
test_string = '{"Nikhil" : 1, "Akshat" : 2, "Akash" : 3}' 
  
# printing original string 
print("The original string : " + str(test_string))
  
# using ast.literal_eval()
# convert dictionary string to dictionary
res = ast.literal_eval(test_string)
  
# print result
print("The converted dictionary : " + str(res))
SuperPro Cz

Python créant un dict à partir d'une chaîne écrite comme un dict

# Python3 code to demonstrate
# convert dictionary string to dictionary
# using ast.literal_eval()
import ast
  
# initializing string 
test_string = '{"Nikhil" : 1, "Akshat" : 2, "Akash" : 3}' 
  
# printing original string 
print("The original string : " + str(test_string))
  
# using ast.literal_eval()
# convert dictionary string to dictionary
res = ast.literal_eval(test_string)
  
# print result
print("The converted dictionary : " + str(res))
SuperPro Cz

Python créant un dict à partir d'une chaîne écrite comme un dict

# Python3 code to demonstrate
# convert dictionary string to dictionary
# using ast.literal_eval()
import ast
  
# initializing string 
test_string = '{"Nikhil" : 1, "Akshat" : 2, "Akash" : 3}' 
  
# printing original string 
print("The original string : " + str(test_string))
  
# using ast.literal_eval()
# convert dictionary string to dictionary
res = ast.literal_eval(test_string)
  
# print result
print("The converted dictionary : " + str(res))
SuperPro Cz

Python créant un dict à partir d'une chaîne écrite comme un dict

# Python3 code to demonstrate
# convert dictionary string to dictionary
# using ast.literal_eval()
import ast
  
# initializing string 
test_string = '{"Nikhil" : 1, "Akshat" : 2, "Akash" : 3}' 
  
# printing original string 
print("The original string : " + str(test_string))
  
# using ast.literal_eval()
# convert dictionary string to dictionary
res = ast.literal_eval(test_string)
  
# print result
print("The converted dictionary : " + str(res))
SuperPro Cz

Réponses similaires à “Python créant un dict à partir d'une chaîne écrite comme un dict”

Questions similaires à “Python créant un dict à partir d'une chaîne écrite comme un dict”

Plus de réponses similaires à “Python créant un dict à partir d'une chaîne écrite comme un dict” dans Python

Parcourir les réponses de code populaires par langue

Parcourir d'autres langages de code