import concurrent.futures
import urllib.request
import json
myurls = {}
for x in range(1, 15):
for y in range(1, 87):
strvar1 = "%s" % (x)
strvar2 = "%s" % (y)
with open("C:\\Python33\\NASDAQ Stock Strings\\NASDAQ_Config_File_{}_{}.txt".format(x,y),"r") as f:
myurls[x,y] = f.read().replace('\n', '')
print("myurls_" + str(strvar1) + "_" + str(strvar2) + "=", myurls[x,y])
def myglob():
global myurls
URLS = [myurls2_1_1,myurls2_1_2,myurls2_1_3,myurls2_1_4,myurls2_1_5 ETC>>>ETC >>>]
下面的代码可以正常工作。这个想法是:
你说呢
没错。但是您已经非常接近了:只需按照您定义它们的方式访问它们:作为
myurls[1,1]
或您如何定义它们。你知道吗以动态的方式定义变量几乎从来不是一种可行的方法;通常您可以通过任何dict键或列表索引访问来实现这一点。你知道吗
如您现在提供的示例所示,我可以确切地说明您的做法:
这是一条路要走。它看起来非常复杂和奇怪,这最后,非常长的一行。你知道吗
但你可以用列表来缩短它:
但是,你可能会被问到:“为什么不在路上建造呢?”你知道吗
好吧,我们开始吧:
你来了。你知道吗
没有必要一次将它们全部放到列表中,因为这与并行化无关,而并行化似乎只是在稍后才出现。你知道吗
重要的是在并行化开始时有
urls
。如果这种情况一次发生或一项一项地发生都无关紧要。你知道吗相关问题 更多 >
编程相关推荐