latin2ascii.py 文件源码

python
阅读 21 收藏 0 点赞 0 评论 0

项目:easyATT 作者: InfiniteSamuel 项目源码 文件源码
def main(argv):
    import getopt, fileinput
    def usage():
        print ('usage: %s [-c codec] file ...' % argv[0])
        return 100
    try:
        (opts, args) = getopt.getopt(argv[1:], 'c')
    except getopt.GetoptError:
        return usage()
    if not args: return usage()
    codec = 'utf-8'
    for (k, v) in opts:
        if k == '-c': codec = v
    for line in fileinput.input(args):
        line = latin2ascii(unicode(line, codec, 'ignore'))
        sys.stdout.write(line.encode('ascii', 'replace'))
    return
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号