小编Ben*_*sse的帖子

在while循环中使用tqdm进度条

我正在制作一个代码模拟一个围绕垄断板的棋子一百万次.我希望有一个tqdm进度条,每次转盘时都会更新.

以下是我目前的代码.我正在使用while循环,当电路板周围的转数超过所需数量时,它会停止.

import os
from openpyxl import Workbook
from monopolyfct import *


def main(runs, fileOutput):

    ### EXCEL SETUP ###
    theWorkbook = Workbook()                              # Creates the workbook interface.
    defaultSheet = theWorkbook.active                     # Creates the used worksheet.
    currentData = ["Current Table Turn", "Current Tile"]  # Makes EXCEL column titles.
    defaultSheet.append(currentData)                      # Appends column titles.

    ### CONTENT SETUP ###
    currentData = [1, 0]             # Sets starting position.
    defaultSheet.append(currentData) # Appends starting position.

    while currentData[0] <= runs:

        ### ROLLING THE DICES PROCESS ### …
Run Code Online (Sandbox Code Playgroud)

python python-3.x tqdm

28
推荐指数
2
解决办法
2万
查看次数

标签 统计

python ×1

python-3.x ×1

tqdm ×1