Eric
0
Q:

split python

persoonsgegevens = "Clarissa Smet, Aktorstraat 12, 3000 Leuven"
txt.split(",")

# Output:
# ["Clarissa Smet", "Aktorstraat 12", "3000 Leuven"]
3
string = 'James Smith Bond'
x = string.split(' ') #Splits every ' ' (space) in the string to a list
# x = ['James','Smith','Bond']
print('The name is',x[-1],',',x[0],x[-1])
2
# Basic syntax:
string.split("text_to_split_by")

# Example usage:
text = "this|is|an|example"
print(text.split("|"))
--> ['this', 'is', 'an', 'example']
2
>>> '1,2,3'.split(',')
['1', '2', '3']
>>> '1,2,3'.split(',', maxsplit=1)
['1', '2,3']
>>> '1,2,,3,'.split(',')
['1', '2', '', '3', '']
1
file='/home/folder/subfolder/my_file.txt'
file_name=file.split('/')[-1].split('.')[0]
15
import pandas as pd
row , coloumn = df.shape
year = [2012,2103,2014,2015]

for i in range(0,row) :
  if df.iloc[i]['A'] =="task1" or df.iloc[i]['A'] == "task2"  :
    if df.iloc[i]['B'] in year and df.iloc[i]['B'] >= 7:
      print(df.iloc[i]['C'])
-1
filename = input("Input the Filename: ")
f_extns = filename.split(".")
print ("The extension of the file is : " + repr(f_extns[-1]))
-2

New to Communities?

Join the community