ValueError:int()的无效文字,基数为10:Python

Moh*_*hit 1 python file-io

我有以下代码.我正在从csv读取并将其内容解析为列表:

import csv
finput = input.reader(open(path,'rb'),delimiter=',',quotechar='|')
print finput[0]
Run Code Online (Sandbox Code Playgroud)

输出是:

['"1239"', '"2249.00"', '"1"', '"3"', '"2011-02-20"']
Run Code Online (Sandbox Code Playgroud)

现在我想提取1239数...第一个元素,所以print finput [0] [0]给出"1239".现在,如果我将其转换为整数:

el = int(finput[0][0])
Run Code Online (Sandbox Code Playgroud)

我收到此错误:

ValueError: invalid literal for int() with base 10: '"1239"'
Run Code Online (Sandbox Code Playgroud)

为什么它有那些双引号?

什么是提取整数的简洁方法1239

ret*_*ile 7

简单来说:

int(finput[0][0].strip('"'))
Run Code Online (Sandbox Code Playgroud)

但是,为什么你设置quotechar|?你确定不应该这样"吗?设置为",你应该得到没有引号的字符串.