本文整理汇总了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')
示例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