![](/img/trans.png)
[英]how to read a specific line and print a specific position in this line using python
[英]python how to read read any specific column of row line by line
我有一個包含多列的 csv 文件。 我想逐行閱讀 url 列,然后訪問每個 url。
這里我的 csv 看起來像:
url sku
https://.. F-01
https://.. F-02
我想做這樣的事情:
for i in url:
visit_every_url = requests.get(i)
cat url_csv
url sku
https://google.com F-01
https://duckduckgo.com/ F-02
import csv
import requests
with open('url_csv', 'r') as csv_file:
reader = csv.DictReader(csv_file, delimiter=' ', skipinitialspace=True)
for row in reader:
r = requests.get(row['url'])
print(r.url)
https://www.google.com/
https://duckduckgo.com/
我猜測了您的 CSV 文件中的delimiter
是什么。 您需要驗證它實際上是空格分隔還是制表符分隔。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.