python-for用法
假設我們想要將for迴圈的資料存成變數,其實可以利用一個空list方式來存取
test = []
sequences = [0, 1, 2, 3, 4, 5]
for i in sequences:
print(i)
test.append(i)
print (test)
test1 = ''.join(str(e) for e in test)
#list1 = ['1', '2', '3']
#str1 = ''.join(list1)
print (test1)
output如下
D:\>python test.py
0
1
2
3
4
5
[0, 1, 2, 3, 4, 5]
012345
留言
張貼留言