python - 如何处理 UFuncTypeError?
问题描述
运行此程序时出现此错误:
UFuncTypeError: ufunc 'add' did not contain a loop with signature matching types (dtype('<U21'), dtype('<U21')) -> dtype('<U21' )
import requests
import numpy as np
username ='xxxxxx'
password ='yyyyyy'
years = np.arange(1961,1967)
for year in years:
url = 'http://aphrodite.st.hirosaki-u.ac.jp/product/APHRO_V1808_TEMP/APHRO_MA/050deg_nc/APHRO_MA_TAVE_050deg_V1808.'+ str(year)+'.nc.gz'
r=requests.get(url,auth=(username,password),allow_redirects=True)
open(str(year+'.gz','wb').write(r.content))
谁能帮助如何消除此错误?我正在尝试从网站下载一个大型数据集。
解决方案
你的最后一行应该是
open(str(year) + 'gz', 'wb').write(r.content)
推荐阅读
- scala - 如何执行 Akka Streams Source?
- javascript - 在 Python 脚本中将 JavaScript 转换回可读的 HTML
- php - 当我没有从用户那里得到输入时不使用 php prepare 语句
- javascript - 理解 Javascript 中的 forEach
- matlab - Matlab中如何判断输入是比率还是浮点数?
- python - 用python删除除URL之外的所有内容
- c++ - OpenGL视频帧拟合
- html - 如何增加图像轮播的不透明度?
- bash - 从具有 700 万行的输入文本文件中获取包含空格的最后一列的 md5 哈希
- operating-system - 主引导记录显示没有活动分区?