Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
1eb9a81e
Kaydet (Commit)
1eb9a81e
authored
Mar 25, 1997
tarafından
Guido van Rossum
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Added new functions replace() and replace1().
üst
c8a80cdb
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
0 deletions
+30
-0
string.py
Lib/string.py
+15
-0
stringold.py
Lib/stringold.py
+15
-0
No files found.
Lib/string.py
Dosyayı görüntüle @
1eb9a81e
...
...
@@ -320,6 +320,21 @@ def maketrans(fromstr, tostr):
L
[
fromstr
[
i
]]
=
tostr
[
i
]
return
joinfields
(
L
,
""
)
# Substring replacement (global)
def
replace
(
old
,
new
,
str
):
return
joinfields
(
splitfields
(
str
,
old
),
new
)
# Substring replacement (1st substring only)
def
replace1
(
old
,
new
,
str
,
i
=
0
,
last
=
None
):
if
last
is
None
:
i
=
find
(
str
,
old
,
i
)
else
:
i
=
find
(
str
,
old
,
i
,
last
)
if
i
>=
0
:
str
=
str
[:
i
]
+
new
+
str
[
i
+
len
(
old
):]
return
str
# Try importing optional built-in module "strop" -- if it exists,
# it redefines some string operations that are 100-1000 times faster.
# It also defines values for whitespace, lowercase and uppercase
...
...
Lib/stringold.py
Dosyayı görüntüle @
1eb9a81e
...
...
@@ -320,6 +320,21 @@ def maketrans(fromstr, tostr):
L
[
fromstr
[
i
]]
=
tostr
[
i
]
return
joinfields
(
L
,
""
)
# Substring replacement (global)
def
replace
(
old
,
new
,
str
):
return
joinfields
(
splitfields
(
str
,
old
),
new
)
# Substring replacement (1st substring only)
def
replace1
(
old
,
new
,
str
,
i
=
0
,
last
=
None
):
if
last
is
None
:
i
=
find
(
str
,
old
,
i
)
else
:
i
=
find
(
str
,
old
,
i
,
last
)
if
i
>=
0
:
str
=
str
[:
i
]
+
new
+
str
[
i
+
len
(
old
):]
return
str
# Try importing optional built-in module "strop" -- if it exists,
# it redefines some string operations that are 100-1000 times faster.
# It also defines values for whitespace, lowercase and uppercase
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment