What do you want to save?
Add Code snippet
New code examples
-
Other 2021-09-27 21:11:03
reading doc in python
from bs4 import BeautifulSoup as bs soup = bs(open(filename).read()) [s.extract() for s in soup(['style', 'script'])] tmpText = soup.get_text() text = "".join("".join(tmpText.split('\t')).split('\n')).encode('utf-8').strip() print text Add solution -
Python 2021-09-25 22:34:02
string methods to clean column dataframe
def clean_col(col): col = col.strip() col = col.replace("(","") col = col.replace(")","") col = col.lower() return col new_columns = [] for c in df.columns: clean_c = clean_col(c) new_co... Add solution -
Python 2021-09-12 23:23:03
how to get user input of list in python
# number of elements n = int(input("Enter number of elements : ")) # Below line read inputs from user using map() function a = list(map(int,input("\nEnter the numbers : ").strip().split()))[:n] print("\nList is - "... Add solution -
Python 2021-09-12 15:09:03
parsing text in python
my_string = 'Names: Romeo, Juliet' # split the string at ':' step_0 = my_string.split(':') # get the first slice of the list step_1 = step_0[1] # split the string at ',' step_2 = step_1.split(',') # strip leading and trailing edge spaces of each item ... Add solution