[問題] print(something,end='') and scope fo …
不好意思,遇到了兩個問題想請教大家..
1.在以下的code中,我發現output並不如我想像中先print出processing
然後在依序print出.,最後print出ok。反而是直接印出全部,可以請
問一下,這段code如果要達成我要的目的,需要再做什麼改變嗎@@?
print('processing',end='')
for i in range(0,10):
time.sleep(0.1)
print('..',end='')
print('ok')
2.在for loop中,針對loop的變數做更改,再該次interation結束後,
仍然不會有任何的改變,如下會print出00234,而非我想要的0000....
可以請教一下原因嗎?
for i in range(0,5):
if(i==1):
i=i-1
print(i,end="")
謝謝大家@@
--
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.115.52.8
※ 編輯: previa 來自: 140.115.52.8 (04/04 00:10)
→
04/04 01:24, , 1F
04/04 01:24, 1F
推
04/04 01:28, , 2F
04/04 01:28, 2F
→
04/04 10:28, , 3F
04/04 10:28, 3F
→
04/04 10:30, , 4F
04/04 10:30, 4F
→
04/04 10:32, , 5F
04/04 10:32, 5F
→
04/05 00:24, , 6F
04/05 00:24, 6F
→
04/05 00:24, , 7F
04/05 00:24, 7F
→
04/05 00:25, , 8F
04/05 00:25, 8F
→
04/05 00:26, , 9F
04/05 00:26, 9F
推
04/05 13:09, , 10F
04/05 13:09, 10F
→
04/05 13:10, , 11F
04/05 13:10, 11F
→
04/07 09:04, , 12F
04/07 09:04, 12F
Python 近期熱門文章
PTT數位生活區 即時熱門文章