當前位置: 首頁>>代碼示例>>Python>>正文


Python UserString.MutableString方法代碼示例

本文整理匯總了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)) 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:23,代碼來源:test_userstring.py

示例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) 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:11,代碼來源:test_py3kwarn.py

示例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) 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:10,代碼來源:test_userstring.py

示例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 
開發者ID:teamtachyon,項目名稱:Quillpad-Server,代碼行數:15,代碼來源:demjson.py


注:本文中的UserString.MutableString方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。