打开python idle,输入:python
1 import tensorflow as tf 2 3 # 建立常量 4 hello = tf.constant('Hello,world!') 5 6 # 建立会话 7 sess = tf.Session() 8 9 # 执行 10 result = sess.run(hello) 11 12 # 关闭会话 13 sess.close() 14 15 # 输出结果 16 print(result)
运行后,若是获得输出b'Hello,world!',证实运行成功。spa
注意事项:code
一、Python3.0之后,使用print result会报错,改成print(result)便可。blog