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)
#!/usr/bin/python import datetime seconds = int(float(open('/proc/uptime').read().split()[0])) print str(datetime.timedelta(0, seconds))[:-3]+chr(0)