DetachCurrentThread()
我需要用单词和位置重新创建原始字符串。它无法返回原始字符串
DetachCurrentThread()
我可以重新创建句子,但我必须使用原始字符串
答案 0 :(得分:0)
这回答:
String = "ask not what your country can do for you ask"
words = String
list_word = String.split()
res=[]
dict_word={}
for i, j in enumerate(list_word):
if j in dict_word:
res.append(dict_word[j])
else:
dict_word[j]=i
res.append(i)
print words
print res
ask not what your country can do for you ask
[0, 1, 2, 3, 4, 5, 6, 7, 8, 0]