다른 함수에서 백분율을 얻은 후 자체 업데이트되는 진행률 표시 줄을 만들었지 만 다음과 같이 추적하는 데 문제가 있습니다. ############. 대신 100 %에 도달 할 때까지 '#'을 오른쪽으로 이동합니다. 아래는 내 코드입니다. 이 방법을 사용하는 이유는 코드를 재사용 할 수 있도록 외부로 나올 백분율이 필요하기 때문입니다. 제발 도와주세요.
import curses
import time
curses.initscr()
def percentage():
loading = 0
while loading < 100:
loading += 1
time.sleep(0.03)
update_progress(loading)
def update_progress(progress):
win = curses.newwin(3, 32, 3, 30)
win.border(0)
rangex = (30 / float(100)) * progress
pos = int(rangex)
display = '#'
if pos != 0:
win.addstr(1, pos, "{}".format(display))
win.refresh()
percentage()
를 전환하여 다음 pos
을 곱할 수 있습니다 display #
.
if pos != 0:
win.addstr(1, 1, "{}".format(display*pos))
win.refresh()
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다