0

I'm really newbie in python programming specially in tensorflow concept, I already installed tensorflow in my PC, But when I make a simple program to execute "Hello Tensorflow" there is something annoyed me, the out put always appear " b' " like this picture. Error Image and my source code like this:

import tensorflow as tf
hello = tf.constant("Hello, TensorFlow!")
sess = tf.Session()
print(sess.run(hello))

anybody may help me to solve this problem please? I'm sorry for my bad english anyway. Thanks

2

1 Answer 1

2

In python 3 there are two types of strings.

  1. byte strings
  2. strings

byte strings are array of characters which are prefixed by b'. In order to convert byte into string one needs to decode it. byte instances have method decode that will convert the byte to normal string. decode method expects encoding usually 'utf-8'.

import tensorflow as tf
hello = tf.constant("Hello, TensorFlow!")
sess = tf.Session()
print(sess.run(hello).decode("utf-8"))
Sign up to request clarification or add additional context in comments.

1 Comment

i'm already used python 3.5.2, and my problem already solved when i add .decode("utf-8") Thanks

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.