Python print 输出到控制台 丢数据

import xlrd
import sys,time

data  = xlrd.open_workbook("C:\Users\Administrator\Desktop\\new1.xlsx")

table = data.sheets()[0]

cols = table.ncols
rows = table.nrows

for i in range(cols):
    fields = table.col_values(i)
    [appname,packet] = fields[:2] 
    # print appname,packet
    for word in fields[2:]:
        sys.stdout.flush()
        # print "1:"+repr(word),
        if len(word.strip())>0:
            #print packet+"|"+word#有时候丟数据
            print packet,"|",word#正常
            time.sleep(0.01)
            sys.stdout.flush()

 

posted @ 2017-04-10 15:15  2BiTT  阅读(2539)  评论(0编辑  收藏  举报