Reputation: 91
images_name = "%s/%03d_image.jpg" % (target, i)
I have formatted it to
images_name = '{:03d_image.jpg}'.format((target, i))
Could you please point me out the mistake?
Also can this be formatted in a better manner?
format_str = ('%s: Step %d, Loss = %.2f (%.1f examples/sec; %.3f '
'sec/batch)')
print(format_str % (datetime.now(), step, loss_value,examples_per_sec, duration))
Upvotes: 1
Views: 1072
Reputation: 78554
You should specify separate placeholders just like you've done with the old-format style and not include parts that do not need formatting within the curly braces:
images_name = '{}/{:03d}_image.jpg'.format(target, i)
The same rule applies to the second string:
format_str = '{}: Step {:d}, Loss = {:.2f} ({:.1f} examples/sec; {:.3f} sec/batch)'
print(format_str.format(datetime.now(), step,
loss_value, examples_per_sec, duration))
Read more about the old and new format specifications in Python.
Upvotes: 1