我已经编写了读取远程系统文件的代码,运行良好,但是读取远程文件需要很多时间。我想提高阅读成绩。在
我还使用python线程来读取远程系统文件。这也需要很多时间。现在有人告诉我更好的建议。在
我用这个代码来读取远程系统文件
root_folder="\\\\192.168.1.1\\C$"
try:
use_dict={}
use_dict['remote']=unicode(root_folder)
use_dict['password']=unicode("example")
use_dict['username']=unicode("example")
win32net.NetUseAdd(None, 2, use_dict)
print "Network connection established"
except:
print "Network connection failed"
for root, dirnames, filenames in os.walk(root_folder):
for filename in filenames:
match=os.path.join(root, filename)
datafile = file(match)
for line in datafile:
for li in line:
print li
根据这段代码,读取远程系统文件需要45分钟的时间。如果我以本地方式读取相同的文件,那么只需要5分钟,所以我无法提高读取的性能。请让我知道提高阅读性能。。。在
谢谢。。。在
你可以尝试多处理。在本例中,一个进程从网络读取数据,另一个进程打印数据,它们通过队列连接起来。在
相关问题 更多 >
编程相关推荐