pythonic

#一种更pythonic的写法:
with open("/data/nbauser.txt") as f, open("/data/result.txt", 'w+') as t:
    for line in f:
        a = line.split("\t")
        t.write("INSERT INTO `user`(`id`, `add_time`) VALUES ('%s', '%s');" %(a[0], a[2]))

你可能感兴趣的:(pythonic)