测试tensorflow版本: 1.13.1
import tensorflow as tf
# 以二进制格式读取文件内容
content = tf.read_file(file_path) # 构建graph中的一个节点,需要在session中运行,
# 才能执行这个操作
# 在session中执行读取文件内容
# 返回类型为:<class 'bytes'>
# 返回值为二进制文件内容
with tf.Session() as sess:
content = sess.run(content)
print(type(content)) # <class 'bytes'>
转载请注明原文地址:https://blackberry.8miu.com/read-4350.html