简体   繁体   中英

python np.loadtxt() giving ValueError: invalid literal for float():

I am trying to create the following variable and keep getting the "ValueError: invalid literal for float():" error.

  pathsets=np.loadtxt('/Volumes/bk/old/6done/post/MAGlist.txt')

MAGlist.txt is of file names like: "070711_after_5mm_46dB_007_VARS"

whats the problem?

By default np.loadtxt uses a dtype (datatype) of float when reading data from a file, you must specify a different type in the call

pathsets=np.loadtxt('/Volumes/bk/old/6done/post/MAGlist.txt', dtype=str)

to get around this error

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