2014-01-31 06:17:30 +00:00
|
|
|
print("".replace("a", "b"))
|
2015-03-14 21:20:58 +00:00
|
|
|
print("aaa".replace("b", "c"))
|
2014-01-31 06:17:30 +00:00
|
|
|
print("aaa".replace("a", "b", 0))
|
|
|
|
print("aaa".replace("a", "b", -5))
|
|
|
|
print("asdfasdf".replace("a", "b"))
|
|
|
|
print("aabbaabbaabbaa".replace("aa", "cc", 3))
|
|
|
|
print("a".replace("aa", "bb"))
|
|
|
|
print("testingtesting".replace("ing", ""))
|
|
|
|
print("testINGtesting".replace("ing", "ING!"))
|
2014-04-07 00:39:13 +01:00
|
|
|
|
|
|
|
print("".replace("", "1"))
|
|
|
|
print("A".replace("", "1"))
|
|
|
|
print("AB".replace("", "1"))
|
|
|
|
print("AB".replace("", "12"))
|
2015-08-21 11:56:14 +01:00
|
|
|
|
|
|
|
try:
|
|
|
|
'abc'.replace(1, 2)
|
|
|
|
except TypeError:
|
|
|
|
print('TypeError')
|
|
|
|
|
|
|
|
try:
|
|
|
|
'abc'.replace('1', 2)
|
|
|
|
except TypeError:
|
|
|
|
print('TypeError')
|