测试tensorflow2版本问题 ,出现告警以及错误。

问题遇到的现象和发生背景

在anaconda4.11.0上测试安装的tensorflow2.8.0。

问题相关代码,请勿粘贴截图

import tensorflow as tf
hello = tf.constant('hello,tensorf')
sess = tf.Session()
print(sess.run(hello))
出现:
AttributeError: module 'tensorflow' has no attribute 'Session'

img

自己查找修改为:
import tensorflow.compat.v1 as tf
tf.disable_v2_behavior()
hello = tf.constant('hello,tensorf')
sess = tf.Session()
print(sess.run(hello))
结果还是错误

运行结果及报错内容

WARNING:tensorflow:From D:\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\compat\v2_compat.py:107: disable_resource_variables (from tensorflow.python.ops.variable_scope) is deprecated and will be removed in a future version.
Instructions for updating:
non-resource variables are not supported in the long term
b'hello,tensorf'
为什么出现 b'hello,tensorf'这个结果

我的解答思路和尝试过的方法

我想要达到的结果

'hello,tensorf'

查询网络一些答案,修改代码后,无错误,
import tensorflow.compat.v1 as tf
tf.disable_v2_behavior()
hello = tf.constant('hello,tensorf')
sess = tf.Session()
sess.run(hello)
print(sess.run(hello))

但是代码运行结果咋是b'hello,tensorf'?怎么多了个b'

img