2024-04-26 12:33:46 发布
网友
我试图在python3.6中拆分。你知道吗
我只需要abc-1.4.0.0
mytext = "_bla.blub = 'abc-1.4.0.0';" #print(mytext) mytext = str.split("_bla.blub = '"); #print (mytext) print (mytext[1].split("'")[0])
但我的结果是空的。为什么?你知道吗
你实际上并不是在对mytext采取行动。你知道吗
mytext
请尝试以下操作:
mytext = "_bla.blub = 'abc-1.4.0.0';" #print(mytext) mytext = mytext.split("_bla.blub = '") #print (mytext) print (mytext[1].split("'")[0])
请执行以下操作:
mytext = "_bla.blub = 'abc-1.4.0.0';" mytext = str.split(mytext); mytext ['_bla.blub', '=', "'abc-1.4.0.0';"] mytext[2] "'abc-1.4.0.0';"
或者
mytext = "_bla.blub = 'abc-1.4.0.0';" mytext = mytext.split("_bla.blub = '") print (mytext[1].split("'")[0]) abc-1.4.0.0
mytext = "_bla.blub = 'abc-1.4.0.0';" mytext = mytext.split("'"); mytext ['_bla.blub', '=', "'abc-1.4.0.0';"] mytext[1] 'abc-1.4.0.0'
mytext = "_bla.blub = 'abc-1.4.0.0';" print(mytext) mytext = mytext.split("'"); print (mytext) print (mytext[0]) print (mytext[1])
您需要对字符串调用.split(),并将其保存到变量中,而不是对str类调用.split()。Try this.
.split()
str
你实际上并不是在对
mytext
采取行动。你知道吗请尝试以下操作:
请执行以下操作:
或者
或者
您需要对字符串调用
.split()
,并将其保存到变量中,而不是对str
类调用.split()
。Try this.相关问题 更多 >
编程相关推荐