#آموزش
🔴 string formating
قسمت دوم
txt = "this is a testing example really is example....wow!!! this is really testing"
print(txt.replace('is', 'was'))
ouput : thwas was a testing example really was example....wow!!! thwas was really testing
print(txt.rfind('z'))
ouput : 64
print(txt.rfind('is', 10,63))
ouput : 59
print(txt.rindex('z'))
#id rindex cant find z give error but rfind give -1
print(txt.split())
ouput : ['this', 'is', 'a', 'testing', 'example', 'really', 'is', 'example....wow!!!', 'this', 'is', 'really', 'testing']
print(txt.split('i',2))
ouput : ['th', 's ', 's a testing example really is example....wow!!! this is really testing']
print(txt.split('i'))
['th', 's ', 's a test', 'ng example really ', 's example....wow!!! th', 's ', 's really test', 'ng']
txt = "this is \ntxting example....\nwow!!!"
print(txt.splitlines())
output : ['this is ', 'txting example....', 'wow!!!']
txt = "This Is txting Example....WOW!!!"
print(txt.swapcase())
output : tHIS iS TXTING eXAMPLE....wow!!!
txt = "tabriz"
print(txt.zfill(20))
output : '00000000000000tabriz'
print(r"how use \n without go to new line", end="\n\n")
output : how use \n without go to new line
#with end you can add somthing at end of string for example i add two new line
for i in range(4):
print(i, end=", ")
output : 0, 1, 2, 3
با تشکر از مهندس
@milad_ghasemi_1
❇️❇️ @raspberry_python
🔴 string formating
قسمت دوم
txt = "this is a testing example really is example....wow!!! this is really testing"
print(txt.replace('is', 'was'))
ouput : thwas was a testing example really was example....wow!!! thwas was really testing
print(txt.rfind('z'))
ouput : 64
print(txt.rfind('is', 10,63))
ouput : 59
print(txt.rindex('z'))
#id rindex cant find z give error but rfind give -1
print(txt.split())
ouput : ['this', 'is', 'a', 'testing', 'example', 'really', 'is', 'example....wow!!!', 'this', 'is', 'really', 'testing']
print(txt.split('i',2))
ouput : ['th', 's ', 's a testing example really is example....wow!!! this is really testing']
print(txt.split('i'))
['th', 's ', 's a test', 'ng example really ', 's example....wow!!! th', 's ', 's really test', 'ng']
txt = "this is \ntxting example....\nwow!!!"
print(txt.splitlines())
output : ['this is ', 'txting example....', 'wow!!!']
txt = "This Is txting Example....WOW!!!"
print(txt.swapcase())
output : tHIS iS TXTING eXAMPLE....wow!!!
txt = "tabriz"
print(txt.zfill(20))
output : '00000000000000tabriz'
print(r"how use \n without go to new line", end="\n\n")
output : how use \n without go to new line
#with end you can add somthing at end of string for example i add two new line
for i in range(4):
print(i, end=", ")
output : 0, 1, 2, 3
با تشکر از مهندس
@milad_ghasemi_1
❇️❇️ @raspberry_python