如何使用“ CSV,阅读器”获取文件中的数据?

时间:2019-06-02 14:45:35

标签: python

我正在尝试使用以下代码:

from csv import reader
c = open('marvel.csv')
v = reader(c)
print(v)

但是,我只能得到这个

<_csv.reader object at 0x103d92c90>

当我应该获得所有Marvel Superheros名称,年龄,性别等...

2 个答案:

答案 0 :(得分:1)

您可以使用以下方法遍历行:

r = reader(c)

for v in r:
    print(v)

答案 1 :(得分:0)

尝试一下:

buildscript {
  repositories {
    maven {
      url "https://plugins.gradle.org/m2/"
    }
  }
  dependencies {
    classpath "com.github.jengelman.gradle.plugins:shadow:5.0.0"
  }
}

apply plugin: "com.github.johnrengelman.shadow"
apply plugin: 'java'

repositories {
  maven {
    url "https://plugins.gradle.org/m2/"
  }
  mavenCentral()
}

configurations {
  v1 {
    extendsFrom(implementation)
  }
  v2 {
    extendsFrom(implementation)
  }
}

dependencies {
    // tweaking deps here
    v1('ant:ant:1.6')
    v2('junit:junit:4.12')
}

task shadowJar1(type: com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar ) {
  classifier = 'v1'
  configurations=[project.configurations.v1]
}
task shadowJar2(type: com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar ) {
  classifier = 'v2'
  configurations=[project.configurations.v2]
}