|
2012-10-07
, 17:55
|
|
Posts: 3,404 |
Thanked: 4,474 times |
Joined on Oct 2005
@ Germany
|
#232
|
The Following User Says Thank You to pycage For This Useful Post: | ||
|
2012-10-09
, 07:25
|
Posts: 771 |
Thanked: 393 times |
Joined on Feb 2012
|
#233
|
Just put a \x00 escape code where you want the output to end (anything beyond it will be ignored, including the forced newline), like so:
print "this string ends here\x00(and this is ignored)"
#!/usr/bin/python import datetime seconds = int(float(open('/proc/uptime').read().split()[0])) print str(datetime.timedelta\x00(0, seconds))[:-3]
|
2012-10-09
, 08:36
|
Posts: 3 |
Thanked: 2 times |
Joined on Oct 2012
|
#234
|
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]
#!/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: | ||
|
2012-10-09
, 09:37
|
Posts: 771 |
Thanked: 393 times |
Joined on Feb 2012
|
#235
|
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)
|
2012-10-09
, 13:57
|
Posts: 397 |
Thanked: 185 times |
Joined on Oct 2011
|
#236
|
|
2012-10-10
, 07:17
|
|
Posts: 1,391 |
Thanked: 4,272 times |
Joined on Sep 2007
@ Vienna, Austria
|
#237
|
|
2012-10-10
, 12:03
|
Posts: 646 |
Thanked: 1,124 times |
Joined on Jul 2010
@ Espoo, Finland
|
#238
|
|
2012-10-13
, 13:36
|
|
Community Council |
Posts: 664 |
Thanked: 1,648 times |
Joined on Apr 2012
@ Hamburg
|
#239
|
@thp: would it be possible to have tags for changing some text to e.g. italic/bold, and for color, e.g. something like:
{i}{full-date}{/i}
{red}{events}{/red}
or would it hit some limitation in LPM mode?
|
2012-10-13
, 15:44
|
Posts: 466 |
Thanked: 418 times |
Joined on Jan 2010
|
#240
|
Uptime: {script:python /home/user/uptime.py}
The Following User Says Thank You to slaapliedje For This Useful Post: | ||
How can I check if the chmod command really went through successfull? - I doubt it did...
To avoid that next time...
Nokia 5110 > 3310 > 6230 > N70 > N9 BLACK 64GB
Hildon Foundation Board member
Maemo Community e.V. co-creator, founder and director since Q4/2016
Current Maemo Community Council member