运行这个代码import pandas as pd from io import StringIO from urllib import request url_csv = "http://bf1.chinazdap.com/skill-help/bigdata/slrh/dongting_investment_min.csv" url_txt = "http://bf1.chinazdap.com/skill-help/bigdata/slrh/dongting_investment_min.txt" data_csv = request.urlopen(url_csv).read().decode(encoding='utf-8') dlists_csv = [rw for rw in StringIO(data_csv)] data_txt = request.urlopen(url_txt).read().decode(encoding='utf-8') dlists_txt = [rw for rw in StringIO(data_txt)]
时间: 2024-04-13 13:25:14 浏览: 278
import pandas as pd.docx
这段代码将从给定的CSV和TXT链接导入数据,并将其存储在dlists_csv和dlists_txt中。
请确保你已经安装了pandas库,然后运行这段代码。在运行之前,你需要将url_csv和url_txt替换为你想要导入的实际链接。
```python
import pandas as pd
from io import StringIO
from urllib import request
url_csv = "http://bf1.chinazdap.com/skill-help/bigdata/slrh/dongting_investment_min.csv"
url_txt = "http://bf1.chinazdap.com/skill-help/bigdata/slrh/dongting_investment_min.txt"
data_csv = request.urlopen(url_csv).read().decode(encoding='utf-8')
dlists_csv = [rw for rw in StringIO(data_csv)]
data_txt = request.urlopen(url_txt).read().decode(encoding='utf-8')
dlists_txt = [rw for rw in StringIO(data_txt)]
```
请确保你在运行代码之前已经连接到互联网,并且可以访问这些链接。
阅读全文