简体   繁体   中英

Removing non- printable data from string

I have a string final line as

['0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.070802847389,0.0,0.0,', '0.0,0.0,0.169140135429,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,', '0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0261263917462,0.0,0.0,0.0,0.0,0.0,0.0,0.0261263917462,0.0,0.0,0.0,0.0,0.0,0.0,', '0.0961428138228,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,', '']

I have to remove last non printable data '' from the string.

Assuming your list is called final_line ,

final_line.remove('') should remove '' from list

You can use

list_name.remove('')
in this case. If you want to delete last element from a list:

 list_name = list_name[:-1] 

or

 list_name.pop() 

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