Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/42.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何解析文本_Python_Python 2.7_Python 3.x_Python Imaging Library - Fatal编程技术网

Python 如何解析文本

Python 如何解析文本,python,python-2.7,python-3.x,python-imaging-library,Python,Python 2.7,Python 3.x,Python Imaging Library,我有这样的想法: a_label= ['At Home', 'Business', 'Food/Clothes', 'Fun', 'Games', 'I see', 'Politics', 'Starting_with_Apolog', 'Work', "['CD', 'IN', 'JJ', 'JJR']", "['CD', 'JJ', 'JJR']", "['CD', 'VBG', 'VBN', 'VBP', 'VBZ', 'WDT']", "['CD', 'VBP', 'VBZ', 'W

我有这样的想法:

a_label=   ['At Home', 'Business', 'Food/Clothes', 'Fun', 'Games', 'I see', 'Politics', 'Starting_with_Apolog', 'Work', "['CD', 'IN', 'JJ', 'JJR']", "['CD', 'JJ', 'JJR']", "['CD', 'VBG', 'VBN', 'VBP', 'VBZ', 'WDT']", "['CD', 'VBP', 'VBZ', 'WDT']", "['DT', 'IN', 'JJ', 'JJR']", "['DT', 'JJ', 'JJR']", "['DT', 'VBG', 'VBN', 'VBP', 'VBZ', 'WDT']", "['DT', 'VBP', 'VBZ', 'WDT']", "['EX', 'IN', 'JJ', 'JJR']", "['EX', 'JJ', 'JJR']", "['EX', 'VBG', 'VBN', 'VBP', 'VBZ', 'WDT']", "['EX', 'VBP', 'VBZ', 'WDT']", "['JJ', 'IN', 'JJ', 'JJR']", "['JJ', 'JJ', 'JJR']", "['JJ', 'VBG', 'VBN', 'VBP', 'VBZ', 'WDT']", "['JJ', 'VBP', 'VBZ', 'WDT']", "['JJR', 'IN', 'JJ', 'JJR']", "['JJR', 'JJ', 'JJR']", "['JJR', 'VBG', 'VBN', 'VBP', 'VBZ', 'WDT']", "['JJR', 'VBP', 'VBZ', 'WDT']", "['JJS', 'IN', 'JJ', 'JJR']", "['JJS', 'JJ', 'JJR']", "['JJS', 'VBG', 'VBN', 'VBP', 'VBZ', 'WDT']", "['JJS', 'VBP', 'VBZ', 'WDT']", "['LS', 'IN', 'JJ', 'JJR']", "['LS', 'VBG', 'VBN', 'VBP', 'VBZ', 'WDT']", "['LS', 'VBP', 'VBZ', 'WDT']", "['NN', 'IN', 'JJ', 'JJR']", "['NN', 'JJ', 'JJR']", "['NN', 'VBG', 'VBN', 'VBP', 'VBZ', 'WDT']", "['NN', 'VBP', 'VBZ', 'WDT']", "['NNP', 'IN', 'JJ', 'JJR']", "['NNP', 'MD', 'NN', 'NNP']", "['NNP', 'NN', 'NNP']", "['NNP', 'VBG', 'VBN', 'VBP', 'VBZ', 'WDT']", "['NNP', 'VBP', 'VBZ', 'WDT']", "['PDT', 'IN', 'JJ', 'JJR']", "['PDT', 'MD', 'NN', 'NNP']", "['PDT', 'VBG', 'VBN', 'VBP', 'VBZ', 'WDT']", "['PDT', 'VBP', 'VBZ', 'WDT']", "['PRP$', 'IN', 'JJ', 'JJR']", "['PRP$', 'MD', 'NN', 'NNP']", "['PRP$', 'VBG', 'VBN', 'VBP', 'VBZ', 'WDT']", "['PRP$', 'VBP', 'VBZ', 'WDT']", "['RBR', 'IN', 'JJ', 'JJR']", "['RBR', 'JJ', 'JJR']", "['RBR', 'VBG', 'VBN', 'VBP', 'VBZ', 'WDT']", "['RBR', 'VBP', 'VBZ', 'WDT']", "['RBS', 'VBG', 'VBN', 'VBP', 'VBZ', 'WDT']", "['RBS', 'VBP', 'VBZ', 'WDT']", "['SYM', 'IN', 'JJ', 'JJR']", "['SYM', 'VBG', 'VBN', 'VBP', 'VBZ', 'WDT']", "['SYM', 'VBP', 'VBZ', 'WDT']", "['UH', 'IN', 'JJ', 'JJR']", "['UH', 'MD', 'NN', 'NNP']", "['UH', 'VBG', 'VBN', 'VBP', 'VBZ', 'WDT']", "['UH', 'VBP', 'VBZ', 'WDT']", "['VBD', 'IN', 'JJ', 'JJR']", "['VBD', 'JJ', 'JJR']", "['VBD', 'VBG', 'VBN', 'VBP', 'VBZ', 'WDT']", "['VBD', 'VBP', 'VBZ', 'WDT']", "['VBG', 'IN', 'JJ', 'JJR']", "['VBG', 'JJ', 'JJR']", "['VBG', 'VBG', 'VBN', 'VBP', 'VBZ', 'WDT']", "['VBN', 'IN', 'JJ', 'JJR']", "['VBN', 'JJ', 'JJR']", "['VBN', 'VBG', 'VBN', 'VBP', 'VBZ', 'WDT']", "['VBP', 'IN', 'JJ', 'JJR']", "['VBP', 'JJ', 'JJR']", "['VBP', 'VBG', 'VBN', 'VBP', 'VBZ', 'WDT']", "['VBZ', 'IN', 'JJ', 'JJR']", "['VBZ', 'JJ', 'JJR']", "['VBZ', 'VBG', 'VBN', 'VBP', 'VBZ', 'WDT']", "['WDT', 'IN', 'JJ', 'JJR']", "['WDT', 'JJ', 'JJR']", "['WDT', 'VBG', 'VBN', 'VBP', 'VBZ', 'WDT']", "['WP$', 'IN', 'JJ', 'JJR']", "['WP$', 'MD', 'NN', 'NNP']", "['WP$', 'VBG', 'VBN', 'VBP', 'VBZ', 'WDT']", "['WP', 'IN', 'JJ', 'JJR']", "['WP', 'JJ', 'JJR']", "['WP', 'VBG', 'VBN', 'VBP', 'VBZ', 'WDT']", 'end__with_ly', 'end_with_al', 'end_with_ful', 'end_with_ible', 'end_with_ic', 'end_with_ive', 'end_with_less', 'end_with_ous', 'sorry_word', 'Gender']
这是一个列表,我希望每个列表项具体如何可能? 它是一个csv标题

DESIRED_COLUMNS =str(a_label).split(",")
print DESIRED_COLUMN
所需的输出将是

At Home
.
.
.
Business 
.
.
['WP', 'JJ', 'JJR'] 
['WP', 'VBG', 'VBN', 'VBP', 'VBZ', 'WDT']

etcc

如果标签已经是一个列表,那么您所要做的就是:

a_label=   ['At Home', 'Business', "['CD', 'IN', 'JJ', 'JJR']", 'Gender']
for item in a_label:                                                     
    print item
这将输出:

At Home
Business
['CD', 'IN', 'JJ', 'JJR']
Gender

试着对你的问题进行更广泛的观察似乎标签已经是一个列表,为什么你要尝试从中创建一个字符串并再次将其解析回一个列表?不,我需要每个列表项分别
>>一个标签[0]
在家中给一个标签[1]给“业务”