我正在学习一门课程,其中我制作了一个打印'*'1 和' '0 的程序。
我想把图像变成0和1。所以我从网站上获取了它,以便我可以用自己的代码打印它。我编写了另一个代码,用于将该未格式化的列表转换为格式化列表,该网站给出了以下结果,我想将其转换为列表。
1000111111111110000111111111111111111111
1001111111111100000111111111111111111111
0001111000000000000011111111111111111111
0001110000000000000011111111111111111111
1000110000000000000011111111111111111111
1110000000110000000011111111111111111111
0000000000111000000011111111111111111111
0000100001110000000011111111111111111111
0001111111100000000011111111111111111111
0000011000000000000011111111111111111111
0000000110000000000011111111111111111111
1100000111000000000011111111111111111111
1110000000000000000011111111111111111111
1110000000000000000111111111111111111111
1111000000000000000111111111111111111111
1111000000000000000111111111111111111111
1111100000000000000111111111111111111111
1110100000000000001111111111111111111111
1110100000000000001111111111111111111111
1000000000000000000011111111111111111111
0000000000000000000011111111111111111111
0000000000000000000011111111111111111111
0000000000000000000011111111111111111111
0000000000000000000011111111111111111111
0000000000000000000011111111111111111111
0000000000000000000011111111111111111111
0000000000000000000011111111111111111111
0000000000000000000011111111111111111111
0000000000000000000011111111111111111111
0000011000000000000011111111111111111111
0000011100000000000011111111111111111111
0010011100000100000011111111111111111111
0100111100000000000011111111111111111111
0001111000000000000111111111111111111111
0011111000000000000111111111111111111111
0010110000011100000011111111111111111111
0000010100000000000111111111111111111111
0000000000000000001111111111111111111111
0000000000000000001111111111111111111111
i = 0
pyt_img = ''
for num in img:
if i == 0:
pyt_img += f'[{num}'
i = i+1
elif i >= 1 & i < 39:
pyt_img += f',{num}'
i = i + 1
elif i >= 40:
pyt_img += f'{num}]\n'
i = 0
print(pyt_img)
问题是它永远不会到达,i = 40所以i = 40线路永远无法工作。
蝴蝶不菲
慕婉清6462132
侃侃尔雅
桃花长相依
相关分类