I need to return time to the millisecond;Python strftime reference provides the %f format place holder, but when I use it in Python 3.x it fails.
This works:
<SPAN class="keyword token">from</SPAN> time <SPAN class="keyword token">import</SPAN> strftime
site <SPAN class="operator token">=</SPAN> <SPAN class="string token">'FP 20180822'</SPAN>
<SPAN class="keyword token">for</SPAN> i <SPAN class="keyword token">in</SPAN> range<SPAN class="punctuation token">(</SPAN><SPAN class="number token">1</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="number token">10</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">:</SPAN>
theTime <SPAN class="operator token">=</SPAN> strftime<SPAN class="punctuation token">(</SPAN><SPAN class="string token">"%H%M%S"</SPAN><SPAN class="punctuation token">)</SPAN>
newTime <SPAN class="operator token">=</SPAN> <SPAN class="string token">'{} {}'</SPAN><SPAN class="punctuation token">.</SPAN>format<SPAN class="punctuation token">(</SPAN>site<SPAN class="punctuation token">,</SPAN>theTime<SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">print</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">'{}'</SPAN><SPAN class="punctuation token">.</SPAN>format<SPAN class="punctuation token">(</SPAN>newTime<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="comment token">#and returns:</SPAN>
FP <SPAN class="number token">20180822</SPAN> <SPAN class="number token">162325</SPAN>
FP <SPAN class="number token">20180822</SPAN> <SPAN class="number token">162325</SPAN>
FP <SPAN class="number token">20180822</SPAN> <SPAN class="number token">162325</SPAN>
FP <SPAN class="number token">20180822</SPAN> <SPAN class="number token">162325</SPAN>
FP <SPAN class="number token">20180822</SPAN> <SPAN class="number token">162325</SPAN>
FP <SPAN class="number token">20180822</SPAN> <SPAN class="number token">162325</SPAN>
FP <SPAN class="number token">20180822</SPAN> <SPAN class="number token">162325</SPAN>
FP <SPAN class="number token">20180822</SPAN> <SPAN class="number token">162325</SPAN>
FP <SPAN class="number token">20180822</SPAN> <SPAN class="number token">162325</SPAN>
<SPAN class="comment token">#the following fails with Invalid format String. </SPAN>
<SPAN class="comment token">#Note the %f which allegedly provides milliseonds</SPAN>
<SPAN class="keyword token">from</SPAN> time <SPAN class="keyword token">import</SPAN> strftime
site <SPAN class="operator token">=</SPAN> <SPAN class="string token">'FP 20180822'</SPAN>
<SPAN class="keyword token">for</SPAN> i <SPAN class="keyword token">in</SPAN> range<SPAN class="punctuation token">(</SPAN><SPAN class="number token">1</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="number token">10</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">:</SPAN>
theTime <SPAN class="operator token">=</SPAN> strftime<SPAN class="punctuation token">(</SPAN><SPAN class="string token">"%H%M%S%f"</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="comment token">#### %f</SPAN>
newTime <SPAN class="operator token">=</SPAN> <SPAN class="string token">'{} {}'</SPAN><SPAN class="punctuation token">.</SPAN>format<SPAN class="punctuation token">(</SPAN>site<SPAN class="punctuation token">,</SPAN>theTime<SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">print</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">'{}'</SPAN><SPAN class="punctuation token">.</SPAN>format<SPAN class="punctuation token">(</SPAN>newTime<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>I was hoping that spinning it through a loop would get me down to the millisecond. Any thoughts? (I can appended i at the end of new Time as a phony millisecond...)