Python 如何获得我想要的输出?
我已经开始使用机器学习的Tensorflow。我是一个初学者,不太了解函数和它们的用途。我从一个简单的Hello world程序开始。我使用的方法是:Python 如何获得我想要的输出?,python,tensorflow,Python,Tensorflow,我已经开始使用机器学习的Tensorflow。我是一个初学者,不太了解函数和它们的用途。我从一个简单的Hello world程序开始。我使用的方法是: import tensorflow as tf hello = tf.constant('hello Tensorflow!') sess = tf.Session() print(sess.run(hello)) 这是输出: FutureWarning: Passing (type, 1) or '1type' as a synonym
import tensorflow as tf
hello = tf.constant('hello Tensorflow!')
sess = tf.Session()
print(sess.run(hello))
这是输出:
FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
_np_qint8 = np.dtype([("qint8", np.int8, 1)])
FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
_np_quint8 = np.dtype([("quint8", np.uint8, 1)])
FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
_np_qint16 = np.dtype([("qint16", np.int16, 1)])
FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
_np_quint16 = np.dtype([("quint16", np.uint16, 1)])
FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
_np_qint32 = np.dtype([("qint32", np.int32, 1)])
FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
np_resource = np.dtype([("resource", np.ubyte, 1)])
FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
_np_qint8 = np.dtype([("qint8", np.int8, 1)])
FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
_np_quint8 = np.dtype([("quint8", np.uint8, 1)])
FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
_np_qint16 = np.dtype([("qint16", np.int16, 1)])
FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
_np_quint16 = np.dtype([("quint16", np.uint16, 1)])
FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
_np_qint32 = np.dtype([("qint32", np.int32, 1)])
FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
np_resource = np.dtype([("resource", np.ubyte, 1)])
WARNING:tensorflow:From C:/Users/visha/PycharmProjects/Object Detection/A.I. for object detection.py:5: The name tf.Session is deprecated. Please use tf.compat.v1.Session instead.
2020-07-16 00:50:02.131405: I tensorflow/core/platform/cpu_feature_guard.cc:142] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX AVX2
**b'hello Tensorflow!'**
Process finished with exit code 0
我想要的输出是“hello Tensorflow”,但开头有一个b。我想知道为什么这是你好Tensorflow代码>转换为字节。例如:
type('Hello')
是str
和type(b'Hello')
是bytes
。你没办法解决这个问题。您可以编辑tensorflow
的代码,但如果您在其他设备上尝试此代码,它将再次打印出b'hello tensorflow!'代码>这是否回答了您的问题b
只需将str
转换为字节
。