擅长:python、mysql、java
<p>假设它们是可以打印的文本文件:</p>
<pre><code>dirpath = 'Z:/HAR_File_Generator/HARS/job_search'
for fn in os.listdir(dirpath):
with open(os.path.join(dirpath, fn), 'r') as f: # open the file
for line in f: # go through each line
print(line) # and print it
</code></pre>
<p>或者,在Python3(或具有适当导入的Python2)中:</p>
<pre><code>dirpath = 'Z:/HAR_File_Generator/HARS/job_search'
for fn in os.listdir(dirpath):
with open(os.path.join(dirpath, fn), 'r') as f: # open the file
print(*f, sep='') # and send every line to the print function
</code></pre>