擅长:python、mysql、java
<p>在Martijn Pieters的帮助下,我想出了一个非常适合我的方法。我是个编程高手,所以我花了一段时间才明白这个问题。以下是最终表现良好的:</p>
<pre><code>fList = []
with open('C:/Users/jhoefler/Desktop/log.txt', 'r') as f:
fList = f.read().split(',')
with suppress(ValueError, AttributeError):
fList.remove('')
fcount = len(fList)
count = 0
progression = 0
for file in fList:
name = os.path.basename(file)
if oApp.Documents.Count < 10:
oDoc = oApp.Documents.Open(file)
else:
pCount = oApp.Documents.LoadedCount
fCount = oApp.Documents.LoadedCount
while fCount == pCount:
time.sleep(1)
pCount = oApp.Documents.LoadedCount
oDoc = oApp.Documents.Open(file)
progression += 1
percent = round(100 * progression / fcount)
print(f'Fortschritt: {progression} / {fcount} ({percent} %) - {name}')
</code></pre>
<p>我确信有一种更优雅的方法来解决这个问题,但它对我的需要很有效。你知道吗</p>