1樓:陳宇軒1
def f(input):
g=[k for i,j in enumerate(input.split("a"),1) for k in (j,str(i))]
g.pop()
return "".join(g)
(似乎沒什麼問題吧。。。
2樓:王龍
test_str
='fasdfasdfasdfasdfdsgffhfghg'
result_str=''
n=1foriin
test_str:if
i=='a':
result_str
+=str(n
)n+=1
else
:result_str+=i
(result_str)
3樓:科先生
indx=2
test_str
='hsdsauwqeqwlkccasdasosa'
test_strs
=test_str
.split
('a'
)str_result=''
fors
intest_strs
:indx=2
ifindx==1
else
1str_result+=s
+str
(indx
(str_result)
python 如何實現遠端tail f?
37丫37 django channels寫個也不複雜,這裡有關於channels的介紹,也有實現tailf的例子 Django使用Channels實現WebSocket 上篇 guyskk tail f是不會結束的,所以你要開新執行緒去讀取日誌並寫入django response 並且respon...
Python 如何實現月份相加?
奚衡 受邀答題,自己DIY了乙個計算這個的函式,思路大致 1 計算出這段指定時間的當天時間凌晨時間和疊加月後的凌晨時間 2 求出相差的天數 3 最後再加天數再指定的時間內疊加即可 usr bin env python coding utf 8 from datetime import datetim...
python如何實現列表交叉合併
蓋世小猛男 all list length1 len res list length2 len res list2 if length1 length2 length length2 elif length1 length2 length length1 else length length1 fo...