本文整理匯總了Python中strop.split方法的典型用法代碼示例。如果您正苦於以下問題:Python strop.split方法的具體用法?Python strop.split怎麽用?Python strop.split使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類strop
的用法示例。
在下文中一共展示了strop.split方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_split
# 需要導入模塊: import strop [as 別名]
# 或者: from strop import split [as 別名]
def test_split(self):
split = strop.split
self.assertTrue(split("this is the split function")
== ['this', 'is', 'the', 'split', 'function'])
self.assertTrue(split("a|b|c|d", '|') == ['a', 'b', 'c', 'd'])
self.assertTrue(split("a|b|c|d", '|', 2) == ['a', 'b', 'c|d'])
self.assertTrue(split("a b c d", None, 1) == ['a', 'b c d'])
self.assertTrue(split("a b c d", None, 2) == ['a', 'b', 'c d'])
self.assertTrue(split("a b c d", None, 3) == ['a', 'b', 'c', 'd'])
self.assertTrue(split("a b c d", None, 4) == ['a', 'b', 'c', 'd'])
self.assertTrue(split("a b c d", None, 0) == ['a', 'b', 'c', 'd'])
self.assertTrue(split("a b c d", None, 2) == ['a', 'b', 'c d'])
示例2: test_split
# 需要導入模塊: import strop [as 別名]
# 或者: from strop import split [as 別名]
def test_split(self):
split = strop.split
self.assert_(split("this is the split function")
== ['this', 'is', 'the', 'split', 'function'])
self.assert_(split("a|b|c|d", '|') == ['a', 'b', 'c', 'd'])
self.assert_(split("a|b|c|d", '|', 2) == ['a', 'b', 'c|d'])
self.assert_(split("a b c d", None, 1) == ['a', 'b c d'])
self.assert_(split("a b c d", None, 2) == ['a', 'b', 'c d'])
self.assert_(split("a b c d", None, 3) == ['a', 'b', 'c', 'd'])
self.assert_(split("a b c d", None, 4) == ['a', 'b', 'c', 'd'])
self.assert_(split("a b c d", None, 0) == ['a', 'b', 'c', 'd'])
self.assert_(split("a b c d", None, 2) == ['a', 'b', 'c d'])