I don't understand why I can't use numpy. after I give it an alias.
I got an error for this.
import numpy as np
ar = numpy.array([1,2,3,4,5])
print(ar)
I can only type
import numpy as np
ar = np.array([1,2,3,4,5])
print(ar)
I don't understand why I can't use numpy. after I give it an alias.
I got an error for this.
import numpy as np
ar = numpy.array([1,2,3,4,5])
print(ar)
I can only type
import numpy as np
ar = np.array([1,2,3,4,5])
print(ar)
That is just how the import ... as
statement behaves. You choose one name for the module you are importing. If you don't have an as
clause, the module’s own name is used.
If you want to call numpy
numpy
, do
import numpy
if you want to call numpy
np
, do
import numpy as np
and if, for some bizarre reason, you want to be able to use either, do
import numpy
np = numpy