I want to place some function in my code that allows me to enter the dictionary key outside the code. I mean to run the program and through the terminal I asked what key of the dictionary I want to place.
To express myself better here is part of the code:
d = (Inventory_data.get("Inventario_datos")).get("Alti DK $ 8 |")
I need that in the terminal when I have executed my program, I asked where is "Alti DK $ 8 |"
, which Key I want. In this case I want "Alti DK $ 8 |"
that's why it's written but I want something like this:
TERMINAL:
(D:\Anaconda2) C:\Users\Marina\Desktop>python auto.py
Name of tag: Aca yo escribiria por ejemplo '"Alti DK $ 4 |"'
And there the whole program would start running. Also, if the same function can be done in some way, but not only introduce one key but several. It should be noted that if I can enter many keys, I need the whole program to be based on the first key, finish and then start with the other one. I do not want to put all the key in my function d
Another way that occurs to me is to create a window instead of the terminal, but I need to create the action I asked them first
Thanks
#!/usr/bin/python
# coding=utf-8
import time
from selenium import webdriver
import xlsxwriter
from Data_tags import Inventory_data
driver = webdriver.Chrome('/Users/Martin/Desktop/chromedriver')
d = (Inventory_data.get("Inventario_datos")).get("SS DK $ 8 |") #Elegir tag para crear a partir del Dic
while True:
tag = input("Ingrese la clave deseada, nada para salir: ")
if not tag:
break
d = (Inventory_data.get("Inventario_datos")).get(tag, "Clave no encontrada")
print(d)
def main():
login("Usuario", "pass")
NewTag("https://platform/en/users/inventory/create")
Device = str(d.get("Li_platform")) #Mobile Web
Inicio_Li_Platform = ('//*[@id="platform_listbox"]/li[')
Final_Li_Platform = (']')
Platform(Inicio_Li_Platform+""+Device+""+Final_Li_Platform)
NameTag(d.get("TagName"))
Floor_Rate(d.get("Floor_price"))
Save_Tag('save')
Save_xlsx(d.get("Excel_name"))
Inicio_Li_Publisher = ('//*[@id="publisher_listbox"]/li[')
Final_Li_Publisher = (']')
Publisher = str(d.get("Li_Publisher")) #Publisher Altitude
Publisher_Li(Inicio_Li_Publisher+""+Publisher+""+Final_Li_Publisher)
Tag_Rate_and_Save(d.get("Tag_Rate"))
time.sleep(2)
driver.close()