python - Sympy fails parsing "01"
问题描述
When I ask sympy to parse a string expression which consists of a number with leading zero(s), it fails. MWE:
parse_expr('01')
gives
ValueError: Error from parse_expr with transformed code: 'Integer (0 )Integer (1 )'
while expected answer is:
1
This is certainly not a bug, but is there a way to prevent such a behavior? Of course, I could first test the string to be parsed with a regex then clean it but I am looking for a solution within sympy environment.
Thank you
解决方案
推荐阅读
- r - 如何在隔离环境中测试/开发 R 中的包?也就是说,独立于系统中已经安装的包
- html - Css:随着窗口大小调整图像上下移动
- appcelerator - appcelerator 可以创建 Android-Auto 兼容的应用程序吗?
- javascript - 在 mongodb 的数组中使用 $gt 运算符更新多个对象
- android - 无法在表格布局中设置分隔线颜色
- generics - 如何在 Rust 中编写递归泛型类型?
- c++ - 为向量分配内存
- c# - 尝试创建新表时对象名称无效
- c# - 如何编写使用 return 关键字的单元测试用例?
- python - 使用 `get_or_create` 时不隐藏软删除的实例