Outils pour utilisateurs

Outils du site


tipstricks:tips_and_tricks

Python - Tips & Tricks

Include local files

import sys
sys.path.append('./lib')
from mycode import *
 
sys.path.append("/opt/kookel/kloud/bin")
import inventory_helper
from kloud_inventory import KloudInventory

Timestamp & delta T

  • timestruct_now_gmt = time.gmtime()
  • time_now_gmt_text = time.strftime(“%Y%m%d-%H%M%S”, time.gmtime())
  • timestruct_converted_from_exemple_string = time.strptime(“20171128-111321”, “%Y%m%d-%H%M%S”)
  • epoch_t1 = time.mktime(timestruct_now_gmt)
  • epoch_t2 = time.mktime(timestruct_converted_from_exemple_string)
  • delta_seconds = epoch_t1 - epoch_t2
  • print(delta_seconds)
tipstricks/tips_and_tricks.txt · Dernière modification: 2019/01/11 16:16 par rguyader