Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/amazon-s3/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何使用代码删除引号?_Python - Fatal编程技术网

Python 如何使用代码删除引号?

Python 如何使用代码删除引号?,python,Python,基本上,我能知道如何将quote\u none添加到我的代码中吗?我正在使用Python 3.7。我正试图让它尽可能简单 csvFile = csv.reader(open("cats.csv",'r')) header = next(csvFile) index = 1 print (header) print("") for row in csvFile : if row[1] >= "35" : print (row) index +=1 这就是我得到的: 1[

基本上,我能知道如何将
quote\u none
添加到我的代码中吗?我正在使用Python 3.7。我正试图让它尽可能简单

csvFile = csv.reader(open("cats.csv",'r'))
header = next(csvFile)
index = 1
print (header)
print("")
for row in csvFile :
  if row[1] >= "35" :
    print (row)
    index +=1
这就是我得到的:

1['Oliver','12','HOPE']
2['Leo','16','SPCA','']
3['Milo','13','ISPCA','
4['Jack','12','SPCA','
5[“乔治”、“14”、“希望”]
6['Bella','10','FFF','
7['Cleo','14','SPCA','']
8['Nala','16','ISPCA',']
9['Teddy','12','SPCA','
10['Zeus','16','SPCA','
11[‘路易’、‘14’、‘爱’、“”]
12['Apollo','11','FFF','
13['George','10','SPCA','
14['Ziggy','11','ISPCA','
预期成果:

1['Oliver,12,HOPE']
2['Leo,16,SPCA']
3['Charlie,18岁,SPCA']
4['Milo,13,ISPCA']
5['Jack,12,SPCA']
6['George,14']
7['Simon,22,SPCA']
8['Loki,24,SPCA']
9['Simba,23,SPCA']
使用
加入

lst = ['Oliver', '12', 'HOPE']
print([','.join(lst)])
所以,在你的例子中,我想这应该是:

print([','.join(row)])

看起来您想要连接每行中的字段(google“concatenate”)。我不明白您是如何决定要抑制哪些行的,您能提出问题并澄清一下吗?如果您比较
if row[1]>=“35”
中的字符串,并且两个打印的字符串(row[1])都不满足if条件,例如
if“12”>=“35”,我看不出您如何从上述代码中获得此输出
将被评估为
False
除了我之前的评论之外,我们这里似乎有XY问题。打印每行时看到的引号不是来自文件,即它们不会受到csv.QUOTE\u NONE的影响。您使用csv模块,所以行是字符串列表,即您打印字符串列表。我怀疑你也想要方括号。你的实际目标是什么?