Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python extract substring

# string [start:end:step]
string = "freeCodeCamp"
print(string[0:len(string)-1])		# freeCodeCam
print(string[0:5])		            # freeC
print(string[2:6])		            # eeCo
print(string[-1])		            # p
print(string[-5:])		            # eCamp
print(string[1:-4])                 # reeCode
print(string[-5:-2])	            # eCa
print(string[::2])		            # feCdCm
Comment

PREVIOUS NEXT
Code Example
Python :: python string cut first n characters 
Python :: python cut string to length 
Python :: python mathematics 
Python :: flask session timeout 
Python :: validate ip address 
Python :: merge two dictionaries 
Python :: sphere volume formula 
Python :: beautifulsoup check if text exists 
Python :: pygame text wrapping 
Python :: how to access variables from a class in python 
Python :: install python3.6 in linux 
Python :: conda create environment python 3 
Python :: ordenar lista decrescente python 
Python :: django queryset to list 
Python :: python opencv measure distance two shapes 
Python :: python ffmpeg get video fps 
Python :: os.chdir go back 
Python :: find number of unique keys in the dictionary 
Python :: regex for repeating words python 
Python :: beautifulsoup usage 
Python :: enumarate in python 
Python :: django start app 
Python :: I have string index in pandas DataFrame how can I select by startswith? 
Python :: python create file in current directory 
Python :: python string to list new line 
Python :: python qt always on top 
Python :: python read binary 
Python :: load python file in jupyter notebook 
Python :: py2exe no console 
Python :: convert 2d aray into 1d using python 
ADD CONTENT
Topic
Content
Source link
Name
3+8 =