Python> Format specification when printing `%`> "% s% s"% ('Hello','World',)

Operating environment


Ubuntu 14.04 LTS desktop amd64
GeForce GTX 750 Ti
ASRock Z170M Pro4S [Intel Z170chipset]
TensorFlow v0.11
cuDNN v5.1 for Linux
CUDA v7.5
Python 2.7.6
IPython 5.1.0 -- An enhanced Interactive Python.

I'm learning a deep learning framework called TensorFlow.

Play down TensorFlow! 4-1. Convolutional Neural Networks http://blog.brainpad.co.jp/entry/2016/04/22/170000

https://www.tensorflow.org/versions/master/tutorials/deep_cnn/index.html

I'm reading a Tutorial that handles CIFAR-10 datasets.

cifar10_train.py


...
        format_str = ('%s: step %d, loss = %.2f (%.1f examples/sec; %.3f '
                      'sec/batch)')
        print (format_str % (datetime.now(), step, loss_value,
                             examples_per_sec, sec_per_batch))
...

It seems to use % to specify the format when printing. http://postd.cc/new-string-formatting-in-python/

Recommended Posts

Python> Format specification when printing `%`> "% s% s"% ('Hello','World',)
[Python] Format when to_csv with pandas
Python string format
Python string format
format in python
python variable expansion, format
[Python] 2's complement conversion
Python callable type specification
Image format in Python
Python Pickle format notes
[Python] format methodical use