^@在运行Python程序时,在Windows上Ubuntu的Bash中随机显示

^@在运行Python程序时,在Windows上Ubuntu的Bash中随机显示,python,bash,bash-on-windows,Python,Bash,Bash On Windows,我有一个python程序,它基本上通过一些CSV进行解析并打印出一行,然后停止,直到用户点击enter。以下是完整的代码: #!/usr/bin/python import os import csv import sys from datetime import datetime teams = [[] for x in xrange(0, 400)] counter = 0 with open('t26.csv', 'rb') as f: next(f) reade

我有一个python程序,它基本上通过一些CSV进行解析并打印出一行,然后停止,直到用户点击enter。以下是完整的代码:

#!/usr/bin/python

import os
import csv
import sys
from datetime import datetime

teams = [[] for x in xrange(0, 400)]
counter = 0

with open('t26.csv', 'rb') as f:

    next(f)

    reader = csv.reader(f)

    for row in reader:
        if row:
            if row[1] <> "" and row[1] <> "TEAM AVERAGES:":
                teams[counter].append(row[16])
                teams[counter].append(row[3])
                teams[counter].append(row[0])
                teams[counter].append(row[4])
                counter += 1


for i in range(0, counter - 1):
    diff = False
    lastTeam = ""
    firstDate = ""

    eid = teams[i][0]
    date = teams[i][1]
    team = teams[i][2]
    pc = teams[i][3] 


    for csvfile in os.listdir('Uploads'):
        with open('Uploads/' + csvfile, 'rb') as f:
            reader = csv.reader(f)

            team_index = 0
            eid_am_index = 0
            eid_pm_index = 0
            find = False

            for row in reader:

                index = 0
                for column_name in row:
                    if "team" == column_name:
                        team_index = index
                    if "eid_am" in column_name:
                        eid_am_index = index
                    if "eid_pm" in column_name:
                        eid_pm_index = index
                    index += 1


                if eid in row:
                    #print row[team_index] + ', ' + row[eid_am_index] + ', ' + row[eid_pm_index] + ', ' + ' ----> ' + csvfile
                    if row[team_index] <> lastTeam and lastTeam <> "":
                        diff = True
                    lastTeam = row[team_index]
                    if firstDate == "":
                        firstDate = csvfile
                    break


    if diff:
        print "\n*diff"
    else: #teams are the same
        team = team[5:]

        if "(" in team:
            team = team[:team.index('(') - 1]

        try:
            lastTeam = lastTeam[:lastTeam.index(' ')]
        except:
            g = 0
        print "\n*no diff: " + eid + " --> " + firstDate + " | " + date + "\tTeam: " + team + " | " + lastTeam + "\tPC: " + pc
        if team <> lastTeam and lastTeam <> "":
            print "*(!) teams not equal"

        f = raw_input('') #read user input and do nothing with it
#/usr/bin/python
导入操作系统
导入csv
导入系统
从日期时间导入日期时间
团队=[]对于x范围内的x(0400)]
计数器=0
以open('t26.csv','rb')作为f:
下一个(f)
读卡器=csv。读卡器(f)
对于读取器中的行:
如果行:
如果第[1]行“”和第[1]行“团队平均值:”:
团队[计数器].追加(第[16]行)
团队[计数器].追加(第[3]行)
团队[计数器].追加(第[0]行)
团队[计数器].追加(第[4]行)
计数器+=1
对于范围内的i(0,计数器-1):
diff=False
lastTeam=“”
firstDate=“”
eid=团队[i][0]
日期=小组[i][1]
团队=团队[i][2]
pc=团队[i][3]
对于os.listdir中的csvfile(“上载”):
将open('Uploads/'+csvfile,'rb')作为f:
读卡器=csv。读卡器(f)
团队指数=0
eid_am_索引=0
eid_pm_索引=0
查找=错误
对于读取器中的行:
索引=0
对于第行中的列名称:
如果“团队”==列名称:
团队索引=索引
如果列名称中的“eid_am”:
eid_am_index=索引
如果列名称中有“eid_pm”:
eid_pm_index=索引
指数+=1
如果行中有eid:
#打印行[team_index]+','+行[eid_am_index]+','+行[eid_pm_index]+','+'--->'+csvfile
如果行[team_index]lastTeam和lastTeam“”:
diff=True
lastTeam=行[团队索引]
如果firstDate==“”:
firstDate=csvfile
打破
如果有差异:
打印“\n*diff”
其他:#团队是一样的
团队=团队[5:]
如果“(”在团队中:
团队=团队[:团队索引(“(”)-1]
尝试:
lastTeam=lastTeam[:lastTeam.index(“”)]
除:
g=0
打印“\n*无差异:”+eid+“-->“+firstDate+”|“+date+”\tTeam:“+team+”|“+lastTeam+”\tPC:“+pc
如果团队lastTeam和lastTeam“”:
打印“*(!)团队不相等”
f=原始输入(“”)#读取用户输入,不进行任何操作
我在Windows上的Ubuntu上的Bash上运行这个程序,有时终端上会随机弹出“^@”符号,然后当我单击enter时,我会得到一个错误

下面是一个关于终端外观的示例(需要解释一些#注释):

*无差异:4903-->6-27-2017 3_44_01 PM.csv | 8/1/2017 1:56:39 PM团队:180-A | 180-A PC:AGENT3-102#此行由python程序打印出来
^@#这是随机出现的
回溯(上次的最新呼叫):#当我按enter键时,出现此错误
文件“parse.py”,第127行,在
f=原始输入(“”)
伊奥费罗
这里还有一个屏幕截图:
^@
表示一个空字节(aka
\x00
),不知何故,它会进入您的
stderr
stdout
。当您的
stdin
出于某种原因被关闭时,
EOFError
可能会被触发。我怀疑bash for windows中有bug。
*no diff: 4903 --> 6-27-2017 3_44_01 PM.csv | 8/1/2017 1:56:39 PM       Team: 180-A | 180-A     PC: AGENT3-102 #this line is printed out by the python program
^@ #this randomly show up
Traceback (most recent call last): #when i hit enter i get this error
  File "parse.py", line 127, in <module>
    f = raw_input('')
EOFError