任何人都可以帮我这个python程序吗?

时间:2017-01-07 08:10:46

标签: python-3.x

def fetch(ent, t):

    # ... your code ...

    # run again after 1000ms
    root.after(1000, fetch, ent, t)

只是打印

追踪(最近一次呼叫最后一次):

文件“C:\ Users \ Kunal Desai \ workspace \ Kunal \ data.py”,第2行,

打开(r'C:/ Users / Kunal Desai / workspace / Kunal / Kunal.csv')作为csvfile:

FileNotFoundError:[Errno 2]没有这样的文件或目录:'C:/ Users / Kunal

德赛/工作区/注:Kunal / Kunal.csv'

1 个答案:

答案 0 :(得分:0)

Python documentation有一个简短的示例,说明如何阅读CSV:

function getClientsInRoom(socketId, room) {
    // get array of socket ids in this room
    var socketIds = io.sockets.adapter.rooms[room];
    console.log("socketIds:" + JSON.stringify(socketIds));
    var clients = [];

    if (socketIds && socketIds.length > 0) {
        //socketsCount = socketIds.lenght;

        // push every client to the result array
        for (var i = 0, len = socketIds.length; i < len; i++) {

            // check if the socket is not the requesting
            // socket
            if (socketIds[i] != socketId) {
                clients.push(chatClients[socketIds[i]]);
            }
        }
    }

    return clients;
}

它显示,>>> import csv >>> with open('eggs.csv', 'rb') as csvfile: ... spamreader = csv.reader(csvfile, delimiter=' ', quotechar='|') ... for row in spamreader: ... print ', '.join(row) Spam, Spam, Spam, Spam, Spam, Baked Beans Spam, Lovely Spam, Wonderful Spam 的结果是您必须迭代而不是直接打印它的对象。