

你是否还记得数学课上学过的 底数(对数) 和 计数系统(进制) ? 让我们来重温练习一下吧。
给你一个字符串格式的正数和一个小于37大于1的整数型底数,用你写出来的方法来把他们转换为底数为10(十进制)的形式。 任务使用数字和‘A-Z’来作为字符串格式的正数。
注意数字无法转换的情况。 例如:“1A”不能用基数9进行转换。对于这些情况,你的函数应该返回-1。
... 两个参数,一个字符串参数的正数和一个整数参数底数。
一个被转换完的十进制整数。
checkio("AF", 16) == 175 checkio("101", 2) == 5 checkio("101", 5) == 26 checkio("Z", 36) == 35 checkio("AB", 10) == -1
在这个任务中你将学会如何处理各种不同进制的数据,以及一些处理异常等知识。
re.match("\A[A-Z0-9]\Z", str_number)
0 < len(str_number) ≤ 10
2 ≤ radix ≤ 36
Become Awesome
- No Ads
- No Limits
- More Content
CheckiO Extensions allow you to use local files to solve missions. More info in a blog post.
In order to install CheckiO client you'll need installed Python (version at least 3.8)
Install CheckiO Client first:
pip3 install checkio_client
Configure your tool
checkio --domain=py config --key=
Sync solutions into your local folder
checkio sync
(in beta testing) Launch local server so your browser can use it and sync solution between local file end extension on the fly. (doesn't work for safari)
checkio serv -d
Alternatevly, you can install Chrome extension or FF addon
checkio install-plugin
checkio install-plugin --ff
checkio install-plugin --chromium
Read more here about other functionality that the checkio client provides. Feel free to submit an issue in case of any difficulties.