a = '''The/AT grand/JJ jury/NN commented/VBon/In a/AT number/NN of/In other/AP topics/NNS ,/,AMONG/In them/PPO the/AT Atlanta/NP and/CC'''{'AT': ['the', 'a'], 'JJ': ['grand'], 'NN': ['jury', 'number'], 'VB': ['commented'], 'In': [ 'on', 'of', 'among'], 'AP': ['other'], 'NNS': ['topics'], ',':[','], 'PPO': ['them'], 'NP':['atlanta'], 'CC': ['and']}將上面的字符串變成下面的字典,但是限定只能用str,list,dictionary相關(guān)的結(jié)構(gòu)來解答題目來源及自己的思路我是將這個字符串的空白去掉形成了列表,然后將列表變成字符串再把反斜杠去掉,但是去掉后,變成了一個個單一的字符串形成的列表,不知道該怎么形成集合的字典。相關(guān)代碼// 請把代碼文本粘貼到下方(請勿用圖片代替代碼)import rea = '''The/AT grand/JJ jury/NN commented/VBon/In a/AT number/NN of/In other/AP topics/NNS ,/,AMONG/In them/PPO the/AT Atlanta/NP and/CC'''b = re.findall('w+/w+', a)c = str(b).split('/')print(c)你期待的結(jié)果是什么?實際看到的錯誤信息又是什么?我目前的思路也有可能是錯的,希望可以指導(dǎo)一下,謝謝!
請問python里字符串如何變成字典?
料青山看我應(yīng)如是
2018-12-22 02:35:54