2

When I run following code using a script I get,

a = np.arange(4, dtype=object).reshape((2,2))
print(a[:,0]);

Result: [0, 2].

But if I run the following code in terminal, I get,

a = np.arange(4, dtype=object).reshape((2,2))
a[:,0]

Result: array([0, 2], dtype=object)

How can I get the 2nd output using print method in a script file?

0

1 Answer 1

5

print defaults to printing the str representation of its arguments. You need the repr representation:

print(repr(a[:, 0]))
Sign up to request clarification or add additional context in comments.

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.