python-3.5, timestamp to YYYYmmDDHHMMSS -
hello every saturday workers! need convert timestamp yyyymmddhhmmss. following works well
timestamp=now_var[27:38] # timestamp string dth_now=( # string date heure datetime.datetime.fromtimestamp( int(timestamp) ).strftime('%y%m%d_%h%m%s') ) # string
but gives alert
file "c:\_python\kwh_compare.py", line 35, in <module> ).strftime('%y%m%d_%h%m%s') valueerror: invalid literal int() base 10: ''
where problem ? thanks
don't know api, "fromtimestamp" needs string instead of int?
otherwise try splitting in several operations
timestamp=now_var[27:38] inttimestamp=int(timestamp) datetimestamp=datetime.datetime.fromtimestamp(inttimestamp) dth_now=datetimestamp.strftime('%y%m%d_%h%m%s')
Comments
Post a Comment