本文整理汇总了Python中UserString.MutableString方法的典型用法代码示例。如果您正苦于以下问题:Python UserString.MutableString方法的具体用法?Python UserString.MutableString怎么用?Python UserString.MutableString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UserString
的用法示例。
在下文中一共展示了UserString.MutableString方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_extended_set_del_slice
# 需要导入模块: import UserString [as 别名]
# 或者: from UserString import MutableString [as 别名]
def test_extended_set_del_slice(self):
indices = (0, None, 1, 3, 19, 100, -1, -2, -31, -100)
orig = string.ascii_letters + string.digits
for start in indices:
for stop in indices:
# Use indices[1:] when MutableString can handle real
# extended slices
for step in (None, 1, -1):
s = self.type2test(orig)
L = list(orig)
# Make sure we have a slice of exactly the right length,
# but with (hopefully) different data.
data = L[start:stop:step]
data.reverse()
L[start:stop:step] = data
s[start:stop:step] = "".join(data)
self.assertEqual(s, "".join(L))
del L[start:stop:step]
del s[start:stop:step]
self.assertEqual(s, "".join(L))
示例2: test_mutablestring_removal
# 需要导入模块: import UserString [as 别名]
# 或者: from UserString import MutableString [as 别名]
def test_mutablestring_removal(self):
# UserString.MutableString has been removed in 3.0.
import UserString
# UserString tests may have already triggered this warning
reset_module_registry(UserString)
with warnings.catch_warnings():
warnings.filterwarnings("error", ".*MutableString",
DeprecationWarning)
self.assertRaises(DeprecationWarning, UserString.MutableString)
示例3: test_main
# 需要导入模块: import UserString [as 别名]
# 或者: from UserString import MutableString [as 别名]
def test_main():
with warnings.catch_warnings():
warnings.filterwarnings("ignore", ".*MutableString has been removed",
DeprecationWarning)
warnings.filterwarnings("ignore",
".*__(get|set|del)slice__ has been removed",
DeprecationWarning)
test_support.run_unittest(UserStringTest, MutableStringTest)
示例4: isstringtype
# 需要导入模块: import UserString [as 别名]
# 或者: from UserString import MutableString [as 别名]
def isstringtype( obj ):
"""Is the object of a Python string type?"""
if isinstance(obj, basestring):
return True
# Must also check for some other pseudo-string types
import types, UserString
return isinstance(obj, types.StringTypes) \
or isinstance(obj, UserString.UserString) \
or isinstance(obj, UserString.MutableString)
# ----------------------------------------------------------------------
# Numeric helpers