我在 GitHub 上有以下网页,我想将其内容导入到 python 特别是 jupyter 笔记本中
import pandas as pd
url = 'https://github.com/stedy/Machine-Learning-with-R-datasets/blob/master/groceries.csv'
file1=open(url,'r')
UnOrgan=file1.read()
但是没有成功
SError: [Errno 22] Invalid argument:
有人可以帮我解决这个问题吗?
最佳答案
您无法将 URL 传递给 open()。尝试使用请求库:
import requests
url = 'https://github.com/stedy/Machine-Learning-with-R-datasets/blob/master/groceries.csv'
response = requests.get(url)
print(response.text)
关于python-3.x - python : how to import csv file from github into text file,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49842542/