^ @在Windows上的Ubuntu上随机出现在Bash上,同时运行Python程序

时间:2017-08-29 17:17:23

标签: python bash bash-on-windows

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

#!/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

我在Windows上的Ubuntu上运行Bash上的这个程序,有时符号“^ @”将在终端上随机弹出,然后当我点击回车时出现错误。

以下是终端的外观示例(有一些#comments解释):

*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

以下是截图: enter image description here

0 个答案:

没有答案