python - How to convert a single big number written in *.txt file into numpy array of its individual digits? -


say, 1 have file.txt 1234567890 number written in it. now, how 1 can convert number numpy.array, ie. [1, 2, 3, 4, 5, 6, 7, 8, 9, 0]?

if want consider each character separate int, can convert string list , list np.array dtype=int. example -

with open('file') f:     narray = np.array(list(f.read()),dtype=int) 

example -

in [50]: np.array(list("1234567890"),dtype=int) out[50]: array([1, 2, 3, 4, 5, 6, 7, 8, 9, 0]) 

Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -