import traceback; print "".join(traceback.format_exception_only(*__exception__))
'hello {0:03d} world {1:05d}'.format(11, 22) .zfill(3) will also work
class Zone(tzinfo): def __init__(self,offset,isdst,name): self.offset = offset self.isdst = isdst self.name = name def utcoffset(self, dt): return timedelta(hours=self.offset) + self.dst(dt) def dst(self, dt): return timedelta(hours=1) if self.isdst else timedelta(0) def tzname(self,dt): return self.name PDT = Zone(-7,False,'PDT') print datetime.utcnow().strftime('%m/%d/%Y %H:%M:%S %Z') print 'PDT:',datetime.now(PDT).strftime('%m/%d/%Y %H:%M:%S %Z')
1 import sys 2 3 s = 'abc123' 4 print type(s) 5 6 u = u'abc123' 7 print type(u) 8 9 print type(s.decode('ascii')) 10 print type(s.encode('utf8')) 11 12 print type(u.decode('ascii')) 13 print type(u.encode('utf8')) output: < type 'str'> < type 'unicode'> < type 'unicode'> < type 'str'> < type 'unicode'> < type 'str'>