"code":-1100,"msg":"Illegal characters found in parameter '^[0-9]{1,20}$'【已解决】

  • InvalidOrder: binance {“code”:-1100,“msg”:“Illegal characters found in parameter ‘startTime’; legal range is ‘1{1,20}$’.”}【已解决】

  • 问题背景

通过ccxt.binance.fetch_ohlcv(symbol, since=millisec)获取symbol的K线数据。出现如题所示问题。

  • 问题原因

Python中float()函数会将小数呈现为科学计数法。

>>> float(0.000001)
1e-06
>>
当 `URLDecoder` 出现 `Illegal hex characters in escape (%) pattern - Error at index 0 in: ""-"` 错误,通常是因为传入的字符串包含非法的 URL 编码字符,`%` 后面没有紧跟有效的十六进制字符。以下是一些解决方法: #### 1. 检查输入字符串 确保输入的字符串是经过正确编码的。可能是在编码过程中出现了问题,或者输入的字符串本身就不是有效的 URL 编码字符串。 ```java import java.net.URLDecoder; import java.nio.charset.StandardCharsets; public class URLDecoderExample { public static void main(String[] args) { String input = "%20"; // 确保这是正确编码的字符串 try { String decoded = URLDecoder.decode(input, StandardCharsets.UTF_8); System.out.println(decoded); } catch (Exception e) { e.printStackTrace(); } } } ``` #### 2. 对输入字符串进行预处理 如果输入字符串中包含非法的 `%` 字符,可以尝试将其替换为合法的编码形式或者直接删除。 ```java import java.net.URLDecoder; import java.nio.charset.StandardCharsets; public class URLDecoderPreprocess { public static void main(String[] args) { String input = "-%ab"; // 简单示例:移除非法的 % 字符 input = input.replaceAll("%[^0-9A-Fa-f]", ""); try { String decoded = URLDecoder.decode(input, StandardCharsets.UTF_8); System.out.println(decoded); } catch (Exception e) { e.printStackTrace(); } } } ``` #### 3. 检查编码字符集 确保使用正确的字符集进行解码。通常,`UTF-8` 是最常用的字符集,但也可能有其他情况。 ```java import java.net.URLDecoder; import java.nio.charset.StandardCharsets; public class URLDecoderCharset { public static void main(String[] args) { String input = "%20"; try { String decoded = URLDecoder.decode(input, StandardCharsets.UTF_8); System.out.println(decoded); } catch (Exception e) { e.printStackTrace(); } } } ```
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值