Где находятся ваши изображения? В папке в вашем проекте? Если это так, вы можете просто сделать что-то вроде этого, чтобы получить все имена файлов изображений:
// Get the path to the app's Assets folder.
string root = Windows.ApplicationModel.Package.Current.InstalledLocation.Path;
string path = root + @"\Assets"; // where your image files are located
// Get the folder object that corresponds to this absolute path in the file system.
StorageFolder folder = await StorageFolder.GetFolderFromPathAsync(path);
IReadOnlyList<StorageFile> items = await folder.GetFilesAsync();
List<string> listOfNames = items.Select(x=>x.Name).ToList();
//or you can leave it as IEnumerable... or you can convert ToArray()
zip ()
ваш друг:
t = ('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h')
zip(t[::2], t[1::2])
[(tuple[a], tuple[a+1]) for a in range(0,len(tuple),2)]
Или, используя itertools
(см. рецепт для группировщика
):
from itertools import izip
def group2(iterable):
args = [iter(iterable)] * 2
return izip(*args)
tuples = [ab for ab in group2(tuple)]
Вот общий рецепт для чанка любого размера, если он не всегда может быть 2:
def chunk(seq, n):
return [seq[i:i+n] for i in range(0, len(seq), n)]
chunks= chunk(tuples, 2)
Или, если вам нравятся итераторы:
def iterchunk(iterable, n):
it= iter(iterable)
while True:
chunk= []
try:
for i in range(n):
chunk.append(it.next())
except StopIteration:
break
finally:
if len(chunk)!=0:
yield tuple(chunk)