num_of_class=5
num_of_division=[1,2,3,4,5]
for j, i in num_of_divisions, range(num_of_class):
kiki=f"Class {i+1} has {j} divisions"
print(kiki)
我期望输出是类似的东西,但是我不知道如何得到它。需要帮助的代码。
Class 0 has 1 divisions
Class 1 has 2 divisions
Class 2 has 3 divisions
Class 3 has 4 divisions
Class 4 has 5 divisions
答案 0 :(得分:0)
使用let im = UIImage(systemName:"circle.fill")?.withTintColor(.red)
let iv = UIImageView(image:im)
并行遍历两个序列中的成对元素:
let im = UIImage(systemName:"circle.fill")?.withTintColor(.red,
renderingMode: .alwaysOriginal)
或者当一个只是一个数字范围时,请使用zip
:
for j, i in zip(num_of_divisions, range(num_of_class)):
# ...
这里的enumerate
意味着for i, j in enumerate(num_of_divisions, 1):
# ...
将从1开始,因此您不必执行1
。