TypeError: NAN/INF not supported in write_number() without 'nan_inf_to_errors' Workbook() option
时间: 2024-02-28 14:53:28 浏览: 51
这个错误通常出现在使用 openpyxl 库写入 Excel 文件时,遇到了 NaN 或 Inf(无穷大)这类非数值类型的数据,而 openpyxl 默认不支持将这些类型的数据写入 Excel 中。
解决这个问题可以在创建 Workbook 对象时,添加参数 `nan_inf_to_errors=True`,这样遇到 NaN 或 Inf 就会被转换成错误类型,避免了写入 Excel 文件时的错误。示例代码如下:
```python
from openpyxl import Workbook
# 创建 Workbook 对象时添加参数 nan_inf_to_errors=True
wb = Workbook(nan_inf_to_errors=True)
```
这样,在写入 Excel 文件时,如果遇到 NaN 或 Inf,就会被转换成错误类型,避免了出现 `TypeError` 的错误。
相关问题
typeerror: nan/inf not supported in write_number() without 'nan_inf_to_errors' workbook() option
这是一个类型错误。在使用 write_number() 函数时,传入了 NaN 或者 Inf,而该函数不能处理这些类型的数据。需要在 workbook() 函数中开启 'nan_inf_to_errors' 选项。
Uncaught runtime errors: × ERROR Failed to execute 'uniform2fv' on 'WebGL2RenderingContext': Overload resolution failed. TypeError: Failed to execute 'uniform2fv' on 'WebGL2RenderingContext': Overload resolution failed. at SingleUniform.setValueV2f [as setValue] (webpack-internal:///./node_modules/_three@0.153.0@three/build/three.cjs:18071:6) at WebGLUniforms.upload (webpack-internal:///./node_modules/_three@0.153.0@three/build/three.cjs:19001:7) at setProgram (webpack-internal:///./node_modules/_three@0.153.0@three/build/three.cjs:29796:19) at WebGLRenderer.renderBufferDirect (webpack-internal:///./node_modules/_three@0.153.0@three/build/three.cjs:28647:20) at renderObject (webpack-internal:///./node_modules/_three@0.153.0@three/build/three.cjs:29346:11) at renderObjects (webpack-internal:///./node_modules/_three@0.153.0@three/build/three.cjs:29315:6) at renderScene (webpack-internal:///./node_modules/_three@0.153.0@three/build/three.cjs:29184:36) at WebGLRenderer.render (webpack-internal:///./node_modules/_three@0.153.0@three/build/three.cjs:28989:5) at Renderer.render (webpack-internal:///./node_modules/photo-sphere-viewer/dist/photo-sphere-viewer.js:7003:21) at Renderer.__renderLoop (webpack-internal:///./node_modules/photo-sphere-viewer/dist/photo-sphere-viewer.js:6991:14)
这是一个 WebGL 渲染过程中的运行时错误,错误信息提示 uniform2fv 函数执行失败。这个函数是用来向 uniform 变量传递一个 vec2 类型的数组的,但是在执行时出现了重载解析错误。可能的原因是传递给 uniform2fv 函数的参数类型不匹配,或者传递参数的数量不正确。建议检查代码中相关的 uniform 变量和对应的传递参数是否正确。