面临这样的任务,从
test = "onetap*https://test.link/1 §neverlose*https://test.link/2 §skeet*https://test.link/3"
print to console:onetap, neverlose, skeet
和 sheet:list = ["https://test.link/1","https://test.link/2","https://test.link/3"]
写了这段代码:
cheatnumber = 1
test = "onetap*https://test.link/1 §neverlose*https://test.link/2 §skeet*https://test.link/3"
cheats = test.rsplit('§', 999)
for cheat in cheats:
cheatnames = cheat.rsplit('*', 1)
for cheatname in cheatnames:
print(" ",cheatnumber,"-",cheatname)
cheatnumber += 1
但它根本不起作用,而不是输出:test, tset, tteesstt
我得到:test,123,tset,321,tteesstt,312
结论