Advertisement
Poganu

Varianta2-Try-Catch

Apr 9th, 2022
692
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.75 KB | None | 0 0
  1.  
  2. try:
  3.     print("00")
  4.     Results_Database['client']['SOMA']['SB-30-SOM']['year'][str(current_year)]['month'][str(current_month)]['day'][str(current_day)]['hour'][str(current_hour)]['Engine_ON'] = 100
  5. except KeyError:
  6.     try:
  7.         print("1")
  8.         Results_Database['client']['SOMA']['SB-30-SOM']['year'][str(current_year)]['month'][str(current_month)]['day'][str(current_day)]['hour'] = str(current_hour)
  9.         Results_Database['client']['SOMA']['SB-30-SOM']['year'][str(current_year)]['month'][str(current_month)]['day'][str(current_day)]['hour'][str(current_hour)]['Engine_ON'] = 100
  10.     except KeyError:
  11.         try:
  12.             print("2")
  13.             Results_Database['client']['SOMA']['SB-30-SOM']['year'][str(current_year)]['month'][str(current_month)]['day'] = str(current_day)
  14.             print(Results_Database['client']['SOMA']['SB-30-SOM']['year'][str(current_year)]['month'][str(current_month)]['day'])
  15.             Results_Database['client']['SOMA']['SB-30-SOM']['year'][str(current_year)]['month'][str(current_month)]['day'][str(current_day)]['hour'] = str(current_hour)
  16.             Results_Database['client']['SOMA']['SB-30-SOM']['year'][str(current_year)]['month'][str(current_month)]['day'][str(current_day)]['hour'][str(current_hour)]['Engine_ON'] = 100
  17.         except KeyError:
  18.             try:
  19.                 print("3")
  20.                 Results_Database['client']['SOMA']['SB-30-SOM']['year'][str(current_year)]['month'] = str(current_month)
  21.                 Results_Database['client']['SOMA']['SB-30-SOM']['year'][str(current_year)]['month'][str(current_month)]['day'] = str(current_day)
  22.                 Results_Database['client']['SOMA']['SB-30-SOM']['year'][str(current_year)]['month'][str(current_month)]['day'][str(current_day)]['hour'] = str(current_hour)
  23.                 Results_Database['client']['SOMA']['SB-30-SOM']['year'][str(current_year)]['month'][str(current_month)]['day'][str(current_day)]['hour'][str(current_hour)]['Engine_ON'] = 100
  24.             except KeyError:
  25.                     print("4")
  26.                     Results_Database['client']['SOMA']['SB-30-SOM']['year'] = str(current_year)
  27.                     Results_Database['client']['SOMA']['SB-30-SOM']['year'][str(current_year)]['month'] = str(current_month)
  28.                     Results_Database['client']['SOMA']['SB-30-SOM']['year'][str(current_year)]['month'][str(current_month)]['day'] = str(current_day)
  29.                     Results_Database['client']['SOMA']['SB-30-SOM']['year'][str(current_year)]['month'][str(current_month)]['day'][str(current_day)]['hour'] = str(current_hour)
  30.                     Results_Database['client']['SOMA']['SB-30-SOM']['year'][str(current_year)]['month'][str(current_month)]['day'][str(current_day)]['hour'][str(current_hour)]['Engine_ON'] = 100
  31.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement