简体   繁体   中英

How can I display numbers in scientific form inside a numpy matrix?

I know the Python code for displaying numbers in scientific form is:

print("Number is {:.2e}".format(Number))

How would I do the same for a (numpy) matrix? I've tried the same format for a 2 by 2 matrix and receive the error message: "TypeError: non-empty format string passed to object. format "

Is there a quick and easy way of displaying all the numbers inside the matrix in scientific form at once?

Here is the exact code that allows you to do this:

j = 0
for j, i in TheMatrix.flat:
    j += 1
    print("The Matrix Value {} is {:.2e}".format(j, i))

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM