On 21/04/15 06:22, lei yang wrote:
start_time = "2014-7-1" revlines = commands.getoutput("git log --pretty=format:'%ad:%an'--date=short --since='%s' --no-merges" %start_time).strip().split('\n') Traceback (most recent call last): File "<stdin>", line 1, in <module> ValueError: unsupported format character 'a' (0x61) at index 26
Your pretty=format argument has a %a in it. Python tries to match percent signs to the values provided but it doesn't know how to process %a. You need to get a literal % sign into your string so you need to double it up. Here is a simpler example: >>> "foo %%5 and %d" % 45 'foo %5 and 45' >>> Alternatively use the more modern subprocess module while helps prevent these kinds of issues by taking all arguments as separate strings in a list. -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ http://www.amazon.com/author/alan_gauld Follow my photo-blog on Flickr at: http://www.flickr.com/photos/alangauldphotos _______________________________________________ Tutor maillist - [email protected] To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
