Cambio de claves y valores en un diccionario en Python [duplicado]
my_dict = {2:3, 5:6, 8:9}
new_dict = {}
for k, v in my_dict.items():
new_dict[v] = k
Gorgeous Gerbil
my_dict = {2:3, 5:6, 8:9}
new_dict = {}
for k, v in my_dict.items():
new_dict[v] = k
# key-values werden erkannt -> Daten werden überschrieben
# key-values = symbol, time -> der Rest wird überschrieben...
insertRates = "INSERT INTO Rates ( symbol, time, open, high, low, close, "
insertRates += "tick_volume, spread, real_volume ) VALUES "
insertRates += "( %s, %s, %s, %s, %s, %s, %s, %s, %s ) "
insertRates += "ON DUPLICATE KEY UPDATE "
insertRates += "open = VALUES( open ), high = VALUES( high ), "
insertRates += "low = VALUES( low ), close = VALUES( close ) , "
insertRates += "tick_volume = VALUES( tick_volume ), spread = VALUES( spread), "
insertRates += "real_volume = VALUES( real_volume ); "