On Apr 21, 2015 12:27 AM, "lei yang" <yanglei.f...@gmail.com> 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 format string has an embedded format string in it. Although you may think it obvious that Python should know not to touch the embedded format string since there are single quotes, Python doesn't take those single quote characters with any reverence. Therefore, it can't tell that you want to keep the embedded one as a literal. Fundamentally, building a command string with string formatting is error prone: consider the subprocess module and passing an explicit list of arguments, rather than a single string. _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor