Sak*_*ura 29 python windows tensorflow
在Windows 10上安装了TensorFlow r0.12(CPU)的测试时,我发现打印的字符串最后总是带有'b'.python的打印是正常的.我无法弄清楚是什么原因来到这里寻求帮助.代码如下:
>>>import tensorflow as tf
>>>hello = tf.constant('Hello, TensorFlow!')
>>>sess = tf.Session()
>>>print(sess.run(hello))
b'Hello, TensorFlow!'
Run Code Online (Sandbox Code Playgroud)
kem*_*mis 44
使用,sess.run(hello).decode()
因为它是一个字节串.decode
方法将返回字符串.
您的print语句必须如下
print(sess.run(hello).decode())
Run Code Online (Sandbox Code Playgroud)