如何添加双重图像?

时间:2015-12-08 06:49:05

标签: python

不确定我在这里做错了什么。我得到的错误是:

let images = [UIImage(named: "Image1")!, UIImage(named: "Image2")!, UIImage(named: "Image3")!]
let yPositions = [0, 204, 693.5, 1186.5]

for (index, image) in images.enumerate() {
    let imageView = UIImageView(image: image)

    if let yPosition = yPositions[index] {
        imageView.frame = CGRectMake(0, CGFloat(yPosition), 375, 395)
    }
}

1 个答案:

答案 0 :(得分:0)

这应该更接近你的意图。

将数据读入dict并计算出现次数:

def count_authors(file_name):
     invert = {}
     for k, v in load_library(file_name).items():
        invert[v] = invert.get(v, 0) + 1
     return invert

然后将数据写入另一个文件:

def write_authors_counts(counts, file_name):
    with open(file_name, 'w') as fobj:
        for name, count in counts.items():
            fobj.write('{}: {}\n'.format(name, count)

将两个功能放在一起:

def report_author_counts(lib_fpath, rep_filepath):
    counts = count_authors(lib_fpath)
    write_authors_counts(counts, rep_filepath))

调用您的函数:

write_authors_counts('file.txt', 'report.txt'))