python json.loads問題

json.loads()傳入的是字符串,同時,字符串中的引號必須是雙引號,否則會報錯。

如:

['S', ['PP', ['ADP', 'In'], ['NP', ['DET', 'the'], ['NP', ['ADJ', '_RARE_'], ['NOUN', '_RARE_']]]], ['S', ['NP', ['ADJ', 'British'], ['NOUN', '_RARE_']], ['S', ['VP', ['VERB', 'were'], ['VP', ['VERB', 'used'], ['S+VP', ['PRT', 'to'], ['VP', ['VERB', '_RARE_'], ['WHNP', ['DET', 'which'], ['NOUN', '_RARE_']]]]]], ['.', '?']]]] #報錯
["S", ["PP", ["ADP", "In"], ["NP", ["DET", "the"], ["NP", ["ADJ", "late"], ["NOUN", "1700<s"]]]], ["S", ["NP", ["ADJ", "British"], ["NOUN", "convicts"]], ["S", ["VP", ["VERB", "were"], ["VP", ["VERB", "used"], ["S+VP", ["PRT", "to"], ["VP", ["VERB", "populate"], ["WHNP", ["DET", "which"], ["NOUN", "colony"]]]]]], [".", "?"]]]] #正確
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章