当前位置: 首页>>代码示例>>Python>>正文


Python String.regionMatches方法代码示例

本文整理汇总了Python中java.lang.String.regionMatches方法的典型用法代码示例。如果您正苦于以下问题:Python String.regionMatches方法的具体用法?Python String.regionMatches怎么用?Python String.regionMatches使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.lang.String的用法示例。


在下文中一共展示了String.regionMatches方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_call_instance_methods

# 需要导入模块: from java.lang import String [as 别名]
# 或者: from java.lang.String import regionMatches [as 别名]
    def test_call_instance_methods(self):
        s = String('hello')
        self.assertTrue(s.regionMatches(1, 1, 'ell', 0, 3),
                        'method call with boolean true')
        self.assertTrue(s.regionMatches(0, 1, 'ell', 0, 3),
                        'method call with boolean false')
        self.assertTrue(s.regionMatches(1, 'ell', 0, 3),
                        'method call no boolean')

        self.assertTrue(s.regionMatches(1, 1, 'eLl', 0, 3),
                                        'method call ignore case')
        self.assertFalse(s.regionMatches(1, 'eLl', 0, 3), 'should ignore case')
开发者ID:isaiah,项目名称:jython3,代码行数:14,代码来源:test_jbasic.py

示例2: BigInteger

# 需要导入模块: from java.lang import String [as 别名]
# 或者: from java.lang.String import regionMatches [as 别名]
assert BigInteger('1234', 10).intValue() == 1234, 'BigInteger(string)'
assert BigInteger([0x11, 0x11, 0x11]).intValue() == 0x111111, 'BigInteger(byte[])'
assert BigInteger(-1, [0x11, 0x11, 0x11]).intValue() == -0x111111, 'BigInteger(int, byte[])'

print 'call static methods'
s1 = String.valueOf(['1', '2', '3'])
s2 = String.valueOf('123')
s3 = String.valueOf(123)
s4 = String.valueOf(123l)
s5 = String.valueOf(['0', '1', '2', '3', 'a', 'b'], 1, 3)
assert s1 == s2 == s3 == s4 == s5, 'String.valueOf method with different arguments'

print 'call instance methods'
s = String('hello')
assert s.regionMatches(1, 1, 'ell', 0, 3), 'method call with boolean true'
assert s.regionMatches(0, 1, 'ell', 0, 3), 'method call with boolean false'
assert s.regionMatches(1, 'ell', 0, 3), 'method call no boolean'

assert s.regionMatches(1, 1, 'eLl', 0, 3), 'method call ignore case'
assert not s.regionMatches(1, 'eLl', 0, 3), 'should ignore case'

from java.awt import Dimension

print 'get/set fields'
d = Dimension(3,9)
assert d.width == 3 and d.height == 9, 'getting fields'
d.width = 42
assert d.width == 42 and d.height == 9, 'setting fields'

#Make sure non-existent fields fail
开发者ID:Alex-CS,项目名称:sonify,代码行数:32,代码来源:test_jbasic.py


注:本文中的java.lang.String.regionMatches方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。