View Single Post
Posts: 3 | Thanked: 2 times | Joined on Oct 2012
#234
Originally Posted by soryuuha View Post
like this?
Code:
#!/usr/bin/python
import datetime
seconds = int(float(open('/proc/uptime').read().split()[0]))
print str(datetime.timedelta\x00(0, seconds))[:-3]
The \x00 is an escape code and must be inside a string literal (that is, inside a quoted piece of text). You can also use the chr() function to get a zero byte. Try the following:
Code:
#!/usr/bin/python
import datetime
seconds = int(float(open('/proc/uptime').read().split()[0]))
print str(datetime.timedelta(0, seconds))[:-3]+chr(0)
 

The Following User Says Thank You to ataristic For This Useful Post: