打開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