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

java - WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/board/] in DispatcherServlet with name 'appServlet' -

android - How to create dynamically Fragment pager adapter -

1111. appearing after print sequence - php -