import time now = time.time() tm = time.localtime(now) print "date->", now print now print time.mktime(tm) """ date-> 1345893254.0 1345893254.0 1345893254.0 """
Posts Related to Python: Afficher l’heure en format Integer
-
Python: Afficher la date et l’heure en plusieurs formats
{filelink=16872} import time # Obtenir l’heure et la date locale now = time.localtime(time.time()) print time.asctime(now) # Afficher la date en format lisible # Personnaliser les …
-
Python: Afficher l’heure et la date actuelle
{filelink=16871} import time now = time.time() print “L’heure et la date actuelle:”, time.localtime(now) print “En utc:”, time.gmtime(now) “”” L’heure et la date actuelle: (2012, 8, …
-
Démarrer un Thread avec la méthode start()
{filelink=16762} import thread import time def print_time(nomThread, delai): “”” Afficher la date et l’heure après les delai spécifié””” while 1: time.sleep(delai) print “%s: %s” % …
-
Afficher des informations sur un fichier
{filelink=16415} import os, time fichier= ‘c:/test.txt’ # Taille de fichier en octets print os.path.getsize(fichier) # Date de dernier accès au fichier print time.ctime(os.path.getatime(fichier)) # Date …
-
GUI: Exemple d’une horloge digitale
{filelink=15429} “”” Python in a Nutshell, 2nd Edition By Alex Martelli ……………………………………….. Publisher: O’Reilly Pub Date: July 2006 Print ISBN-10: 0-596-10046-9 Print ISBN-13: 978-0-59-610046-9 “”” …
-
Python;*: Exemple de conversion des dates
{filelink=16873} import time try: strptime = time.strptime except AttributeError: from strptime import strptime print strptime(“31 Nov 2012”, “%d %b %y”) print strptime(“1 Jan 70 1:30pm”, …
-
Collecter les liens d’une page web
{filelink=16682} “”” Tiré du livre gratuit “Plongez au coeur de Python”, Pour plus d’information. Visitez http://diveintopython.net/ “”” __author__ = “Mark Pilgrim (mark@diveintopython.org)” __version__ = “$Revision: …
-
Exemple d’utilisation de la méthode ‘update’ pour modifier un dictionnaire
{filelink=15990} # Définition d’un dictionnaire con_str = {“host”:”127.0.0.1″, “database”:”mysql”, “user”:”root”, “pwd”:”mysql”} # Afficher les éléments print con_str.items() # Modifier un élément dans le dictionnaire con_str.update({“database”:”mysql2″}) …
-
Exemple d’animation à l’aide des Threads(code externe)
{filelink=15415} #/* #Python and Tkinter Programming #John E. Grayson #ISBN: 1884777813 #Publisher: Manning #*/ from Tkinter import * import thread, time trace = 0 class …
-
Exemple de combinaison des dictionnaires
{filelink=16011} pair = [2, 4, 6, 8] impair= [1, 3, 5, 7, 9] dict={‘pair’:pair, ‘impair’:impair} params = {‘Police’: 12, ‘Style’: ‘Gras’, ‘Couleur’: [255, 0, 255]} …