Recently written LeetCode Code encountered a few small knowledge points to sum up .
1. A list merges its own elements , It is different from two lists merging one list ( This just needs l1+l2 You can merge )
a = ['d','a','t','a']
k = 0
a_str = ' '
while k<len(a):
a_str = a_str + str(a[k])
k +=1
print(a_str)
# 'data'
2.dataframe Remove specified characters
# 'I like football\n' Get rid of \n, It can also be other characters
data['label'] = data['label'].apply(lambda x: x.replace("\n", ""))
# Output :I like football
3.dataframe Add data line by line
data = pd.DataFrame(columns=['api', 'label'])
# i It's the index , insert_data Is the data to be added to this row , use iloc It's fine too
data .at[i, 'api'] = insert_data