代码实现:
import tensorflow as tf assert tf.__version__.startswith('2.') a=tf.constant(2.) b=tf.constant(4.) print(f'{a}+{b}={a+b}')
执行结果: