小编Cra*_*g H的帖子

Python kludge将UCS-2(UTF-16?)读取为ASCII

我对这个问题有点过头了,所以请提前原谅我的术语.

我在Windows XP上使用Python 2.7运行它.

我发现一些Python代码读取日志文件,做一些事情,然后显示一些东西.

什么,这还不够详细?好的,这是一个简化版本:

#!/usr/bin/python

import re
import sys

class NotSupportedTOCError(Exception):
    pass

def filter_toc_entries(lines):
    while True:
        line = lines.next()
        if re.match(r""" \s* 
                   .+\s+ \| (?#track)
                \s+.+\s+ \| (?#start)
                \s+.+\s+ \| (?#length)
                \s+.+\s+ \| (?#start sec)
                \s+.+\s*$   (?#end sec)
                """, line, re.X):
            lines.next()
            break

    while True:
        line = lines.next()
        m = re.match(r"""
            ^\s*
            (?P<num>\d+)
            \s*\|\s*
            (?P<start_time>[0-9:.]+)
            \s*\|\s*
            (?P<length_time>[0-9:.]+)
            \s*\|\s*
            (?P<start_sector>\d+)
            \s*\|\s*
            (?P<end_sector>\d+)
            \s*$
            """, line, re.X)
        if not m:
            break
        yield m.groupdict()

def calculate_mb_toc_numbers(eac_entries):
    eac = list(eac_entries)
    num_tracks = …
Run Code Online (Sandbox Code Playgroud)

python encoding

2
推荐指数
1
解决办法
6618
查看次数

标签 统计

encoding ×1

python ×1