本文整理汇总了Python中inc.Commons.Commons.get_digits_from_start_or_end方法的典型用法代码示例。如果您正苦于以下问题:Python Commons.get_digits_from_start_or_end方法的具体用法?Python Commons.get_digits_from_start_or_end怎么用?Python Commons.get_digits_from_start_or_end使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类inc.Commons.Commons
的用法示例。
在下文中一共展示了Commons.get_digits_from_start_or_end方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_get_digits_from_start_or_end
# 需要导入模块: from inc.Commons import Commons [as 别名]
# 或者: from inc.Commons.Commons import get_digits_from_start_or_end [as 别名]
def test_get_digits_from_start_or_end(self):
string1 = "$12*17"
assert Commons.get_digits_from_start_or_end(string1) == "17", "Failed to get digits from end"
string2 = "cos(tan(12+t+15))"
assert Commons.get_digits_from_start_or_end(string2) is None, "Should not have got any digits from string"
string3 = "hello"
assert Commons.get_digits_from_start_or_end(string3) is None, "Did not return None when no calculation found"
string4 = "£13.50"
assert Commons.get_digits_from_start_or_end(string4) == "13.50", "Failed to get number from end"
string5 = "23f234"
assert Commons.get_digits_from_start_or_end(string5) == "23", "Function should prioritise number at start"
string6 = "tasty pie"
assert Commons.get_digits_from_start_or_end(string6) is None, "Should not have got any digits from string"
string7 = "2e7c"
assert Commons.get_digits_from_start_or_end(string7) == "2e7", "Function should be able to get e notation"