split 函式實現

2022-07-30 14:18:17 字數 786 閱讀 1341

#

split函式實現:

ss='

** *axx* *bv** *ctt** **dff***

'result=

def split_1(ss,a,times=len(ss)):

i=0n=0

while len(ss)!=0 and iand nif ss[i:i+len(a)]==a:

print('i:'

,i)

print('

之前的ss:

',ss)

print

(result)

ss=ss[i+len(a):]

n+=1 #

n是分割次數,每分割一次記錄+1

i=0 #

ss重新賦值了*後面的資料,i需要重新初始化為0

print('

之後的ss:

',ss)

else

:

i+=1

print('

最後的i:

',i)

else

:

return

result

print(split_1(ss,'

',100))

#split 處理以空白分割的情況

ss= 'abc \t \t \n\r bcf \n\rff'

aa='' #臨時儲存非空白字串

result=

i=0while i

oracle實現split函式

oracle資料庫中某乙個字段可能存在以某些特殊符號隔開的字段,我們在查詢使用的時候往往需要將這些欄位spilt開 但是oracle沒有這個函式,網上搜尋了一下,找了乙個可以使用的函式 下面直接上指令碼 1.先建立乙個type create or replace type obj target as...

c 實現split函式

今天工作因原因,需要實現乙個split的功能,以前也做過,但一直沒有把他記下來,所以又重新寫了一次。這次做個筆記以備後用,各位感興趣也可以直接拿來用過。例子 乙個這樣的字串 123,456,789,0 把他擷取成這樣的字串陣列 123 456 789 0 眾所周知c 預設沒有提供這樣功能的函式,下面...

mysql函式split功能實現

先設定 set global log bin trust function creators 1 1.函式func splitstringtotal 將字串按指定方式分割,並計算單元總數 複製 如下 delimiter create function func get splitstringtota...