-1

I have a variable that when I print it gives the value

"[[247 164][249 190][255 215][261 239][270 263][286 283][305 300][324 317][345 320][367 315][388 297][408 277][425 254]..."

and I am wondering if i could set the print value to a variable like:

a = print b
12
  • 1
    No, print returns None. Why would you want to do this? Check xy. Commented Apr 10, 2018 at 13:56
  • @kabanus because the array being printed is a numpy array which I cant upload to a sql database, so i was hoping i could upload it as a string, trying to change the numpy array i have tried : Commented Apr 10, 2018 at 13:58
  • @kabanus arr = opencvImage #ts = arr.tostring() #tol = np.frombuffer(ts, dtype=int) and : import pickle tss = pickle.dumps(arr) tam = pickle.loads(tss) Commented Apr 10, 2018 at 13:59
  • 3
    Then ask "How do I insert a numpy array into a sql database" and give an example of what you actually want to do, and relevant code. Commented Apr 10, 2018 at 13:59
  • What you asked has nothing to do with your problem. Commented Apr 10, 2018 at 14:00

2 Answers 2

1

Im not 100% sure what you are trying to accomplish but if you want the variable to be a string just do:

a = str(b)
Sign up to request clarification or add additional context in comments.

Comments

0

I believe you are trying to do is convert the numpy array to a string, this can be done using python's str function, like so:

b = np.array([1, 2, 3])
a = str(b)

Comments

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.