python - After splitting add newline -


after splitting add newline. both queue size = 3; how split without '\n' in end

source.txt:

 234;234 456;567 4567;6789 

exec:

 open('source.txt') line:     source in line:         result = source.split(";")         qm.put(result[0])         qp.put(result[1])         print(result[0])         print(result[1])         print('----') 

result:

 234 234  ---- 456 567  ---- 4567 6789 ---- 

please check this: using strip()

import queue  qm = queue.queue() qp = queue.queue()  open('txt') line:     source in line:         result = source.strip().split(";")         qm.put(result[0])         qp.put(result[1])         print(result[0])         print(result[1])         print('----') 

output:

 234  234  ----  456  567  ----  4567  6789  ---- 

Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -