gpt4 book ai didi

ruby - 只有当电子表格打开文件时 URI 必须是 ascii?

转载 作者:数据小太阳 更新时间:2023-10-29 08:03:11 26 4
gpt4 key购买 nike

我想读取excel文件,我用下面的代码打开excel:

file = Roo::Spreadsheet.open(file_path)

但是当file_path包含日文时,会出现错误:

URI::InvalidURIError: URI must be ascii only "/Users/myname/Project/Test/tmp/data/\u{611b}\u{77e5}\u{770c}/s000226.xlsx"

我尝试使用 URI 来解析 file_path 但没有成功。如何解决?谢谢你。

最佳答案

你可以试试

File.open(path, 'rb') do |file|
xlsx = Roo::Spreadsheet.open(file, extension: '.xlsx')
end

关于ruby - 只有当电子表格打开文件时 URI 必须是 ascii?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35695146/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com