Am Mittwoch, 5. Januar 2005 11:21 schrieb Christian Klinger:
Hallo
ich bin gerade dabei ein altes perl script zu pythonisieren.
Hierbei treffe ich auf folgendes Konstrukt (ps: leider wenig Ahnung was das macht):
#################################### my $ts=time; print $ts; my @ts = ( (($ts & 0xff000000) >> 24), (($ts & 0xff0000) >> 16), (($ts & 0xff00) >> 8), (($ts & 0xff)) );
print "\n"; print @ts; print "\n";
###################################
Kann mir jemand sagen was das macht, und wie kann man das in Python umsetzen?
Die wörtliche Übersetzung lautet wohl import time ts = int(time.time()) print ts ts = [((ts & 0xff000000) >> 24), ((ts & 0xff0000) >> 16), ((ts & 0xff00) >> 8), ((ts & 0xff))] print "".join(map(str, ts)) Eine Zeitangabe (Sekunden seit "epoch") als 32-Bit Integer wird in Bytes zerlegt, deren Dezimaldarstellung dann zu einem String zusammengeklebt. Die resultierende Ziffernfolge ist ziemlich sinnlos, da sich die ursprüngliche Zeit daraus nicht mehr rekonstruieren lässt. Peter _______________________________________________ python-de maillist - python-de@python.net http://python.net/mailman/listinfo/python-de