python - TensorFlow 中实际输出之前的额外 'b'

标签 python tensorflow canopy

<分区>

所以,我是 TensorFlow 的新手,并且才刚刚开始学习它。我使用“pip”命令在 IDE Canopy 上安装了 TensorFlow。

在确认是否安装正确的同时,我输入了以下代码:

import tensorflow as tf
hello = tf.constant('Hello, TensorFlow!')
sess = tf.Session()
print(sess.run(hello))

这应该给出一个输出:

Hello, TensorFlow!

相反,我得到一个额外的字母“b”,在此之前,例如:

b'Hello, TensorFlow!'

这是一个需要解决的问题,还是可以,如果我对此不做任何事情就可以了? 非常感谢。

最佳答案

'b' 表示它是一个字节串(而不是八位字节序列)。使用 decode() 获取字符串。

print(sess.run(hello).decode())

关于python - TensorFlow 中实际输出之前的额外 'b',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51151436/

相关文章:

python - 如何根据所有列的条件从 Pandas 数据框中排除行

python - Django 查询不以整数形式返回 id 值

javascript - 使用 Tensorflow.js 和 tf.Tensor 处理大数据的最佳方式是什么?

python - 安装 Python 时出现问题

python - 帮助处理 python Entry 小部件中的 <key> 事件

将自身更改为列表的python函数

image-processing - 智能手机上的人体姿势估计/匹配

没有参数的 TensorFlow Serving 导出签名

python - 注释掉 Enthought Canopy 中的代码块

Python 树冠 NumPy : Running the code by pressing "Play" doesn't give the same result as copying and pasting the code in the command line