添加try和except时使用制表符和空格不一致

时间:2016-06-19 16:06:05

标签: python

我收到错误:当我尝试添加try和错误处理时,标签和空格的显式使用错误。我试图让脚本只是跳到下一个url,当一个不存在时。欢迎任何帮助。

for url in get_lines(ARGS.urls_file):
    print("Downloading %s" % url)

    post_paths = refs_to_entries(download(url))
try:
    for ppath in post_paths[:POST_DOWNLOADED]:
        purl = with_path(url, ppath)

        print("Processing %s" % purl)

        marks = MarksCollector.get_all(download(purl))

        h2_marks = marks_inside_ptitle(marks)

        h2_marks = drop_empty_data(h2_marks)

        small = get_small_data(h2_marks)
        price = get_price_data(h2_marks)
        name = get_title_data(h2_marks)
        title = merge_title(name, price, small)

        #print(small, price, name, title, sep = '|||' )

        if title == None:
            print("Skipping (no title)")
            continue

        post = Post(purl, title, name, price, small)

        for ab in attrgroups_bounds(marks):
            for attr in parse_attrgroup(marks, ab):
                post.append_tag(attr[0], attr[1])

        posts.append(post)

    for p in posts:
        p.create_xml_node(root)

write_file(ARGS.output_xml, pretty(root))


time.sleep(SEND_TIMEOUT)

except:
    pass

1 个答案:

答案 0 :(得分:0)

  

write_file(ARGS.output_xml,pretty(root))

     

time.sleep(SEND_TIMEOUT)

我认为这两行需要缩进。