Professional Documents
Culture Documents
Python For Og Lecture 12 Methods in Strings Part 2
Python For Og Lecture 12 Methods in Strings Part 2
Website - https://petroleumfromscratchin.wordpress.com/
LinkedIn - https://www.linkedin.com/company/petroleum-from-scratch
YouTube - https://www.youtube.com/channel/UC_lT10npISN5V32HDLAklsw
Strip Method
print(fav_sub)
Drilling
# lstrip method
fav_sub.lstrip() /
1/30/2021 Python for Oil and Gas Lecture 12 - Methods in Strings Part 2 - Colaboratory
'Drilling'
print(fav_sub)
Drilling
# This lstrip() method not only remove the space bar. It removes any leading characters. By default it is space bar
var = '///----var....python'
'python'
var.lstrip('v/a.r-')
'python'
print(var)
///----var....python
var.lstrip('v/a.r-').upper()
'PYTHON'
/
1/30/2021 Python for Oil and Gas Lecture 12 - Methods in Strings Part 2 - Colaboratory
additive.replace('Bentonite', 'Barite')
print(additive)
print(additive_2)
drill_mud = 'Drilling mud is used to lubricate the bit. This mud also helps us to achieve pressure overbalance. Drill mud also helps in lifting drill cuttings
print(drill_mud)
Drilling mud is used to lubricate the bit. This mud also helps us to achieve pressure overbalance. Drill mud also helps in lifting drill cuttings
drill_mud.replace('mud', 'fluid') # this will replace all the mud with fluid
'Drilling fluid is used to lubricate the bit. This fluid also helps us to achieve pressure overbalance. Drill fluid also helps in lifting drill cuttings
'
drill_mud.replace('mud', 'fluid', 1)
/
1/30/2021 Python for Oil and Gas Lecture 12 - Methods in Strings Part 2 - Colaboratory
'Drilling fluid is used to lubricate the bit. This mud also helps us to achieve pressure overbalance. Drill mud also helps in lifting drill cuttings '
drill_mud.replace('mud', 'fluid', 2)
'Drilling fluid is used to lubricate the bit. This fluid also helps us to achieve pressure overbalance. Drill mud also helps in lifting drill cuttings '
Find method
print(drill_mud)
Drilling mud is used to lubricate the bit. This mud also helps us to achieve pressure overbalance. Drill mud also helps in lifting drill cuttings
drill_mud.find('mud')
drill_mud.find('mud', 0)
drill_mud.find('mud', 10)
48
drill_mud.find('mud', 49)
105
/
1/30/2021 Python for Oil and Gas Lecture 12 - Methods in Strings Part 2 - Colaboratory