Durng安装在Windows 10上的TensorFlow r0.12(CPU)的testing,我发现打印的string总是带有'b'的结尾。 python的打印是正常的。 我找不出原因来到这里寻求帮助。 代码如下:
>>>import tensorflow as tf >>>hello = tf.constant('Hello, TensorFlow!') >>>sess = tf.Session() >>>print(sess.run(hello)) b'Hello, TensorFlow!'
使用hello.decode()
因为它是一个字节hello.decode()
。 decode
方法将返回字符串。