import tensorflow.compat.v1 as tf
tf.compat.v1.disable_eager_execution()
hello = tf.constant('Hello, world!')
# 启动TensorFlow会话
sess = tf.Session()
# 运行 hello 节点
print(sess.run(hello))
sess.close()
注意!不要直接这么写import tensorflow as tf,不然tensorflow2.0版本不兼容1.0!!!



