-1

我正在打开一个包含链接的 .csv 文件,并且我想导航到每个链接。但是当我打印链接列表时,它周围有括号和单引号。如何打印没有括号和单引号的链接?

import csv
import os

with open('links.csv', 'r') as f:
  reader = csv.reader(f)
  links = list(reader)

for i in links:
    print(i)

结果

['https://links.com/100GLC-PFAQ-6X9?idc=43']
['https://links.com/100GLC-PFAQ-9X12?idc=43']
['https://links.com/100LB-PFLIN-9X12?idc=43']
['https://links.com/14PT-PFUV-5.25X10.5?idc=43']
['https://links.com/14PT-PFUV-6X9?idc=43']
['https://links.com/14PT-PFUV-9X12?idc=43']

更新 我使用 *. 下面是我更新的代码。

import csv
import os

with open('links.csv', 'r') as f:
  reader = csv.reader(f)
  links = list(reader)

for i in links:
    print(*i)
4

2 回答 2

0

你可以做下一步:

import csv
import os

links = []

with open('links.csv', 'r') as f:
  reader = csv.reader(f)
  links.extend(reader)

print(links) # show all links without for loop
于 2020-01-17T06:36:52.367 回答
0

我使用 *. 下面是我更新的代码。

import csv
import os

with open('links.csv', 'r') as f:
  reader = csv.reader(f)
  links = list(reader)

for i in links:
    print(*i)
于 2020-01-30T15:03:15.683 回答