import tensorflow as tf
state=tf.Variable(0,name='counter')
##print(state.name)
one=tf.constant(1)
new_value=tf.add(state,one)
update=tf.assign(state,new_value)
##init=tf.initialize_all_variables() #有定义变量要用... 老用法
init=tf.global_variables_initializer() 新用法
with tf.Session() as sess:
sess.run(init)
for _ in range(3): for空格_空格in......
sess.run(update)
print(sess.run(state))