I have two py files, one for grabbing data, generating Excel is a, and one for emailing the generated Excel to b.
I"m calling an in b now, but a needs a parameter, and I can"t give that parameter in a because it"s given in b.
so an is wrong because there are no parameters defined in a.
this is a code snippet of a whose function requires the code parameter:
def get_content(code):
arry = None
code_url = input_code(code)
urlss = start_url(code_url)
for url in urlss:
c = content(url)
if c != []:
-sharp print(c)
z = list(zip(*c))
-sharp print("get : " + str(z))
if arry == None:
arry = z
print(arry)
else:
arry = arry + z
return arry
def main(code):
arry = get_content(code)
param = create_excel()
workbook = param[0]
sheet = param[1]
biaotou = []
tab_head(sheet,biaotou)
row = 1
for i,v in enumerate(arry):
for j,k in enumerate(v):
write_excel(sheet,row,j,k)
file_path = "E:/Anaconda3/project/test/%s.xls" % str(str(arry[0][0]) + "(" + str(arry[0][1]) + ")")
row += 1
save_excel(file_path,workbook)
print("")
this is a code snippet of b, which passes the code parameter:
for codes in code_eamil:
cd = codes[0]
em = codes[1]
for code in cd:
print(":" + str(code))
a_gu = "http://quotes.*******.*****.com/trade/%s.html" % str(code)
if requests.get(a).status_code == 200:
a = requests.get(a).text
try:
times = re.search("<tr class=".*?"><td>(.*?)</td>",a_gu_html,re.S).group(1)
main(code)
print("")
then run time:
Traceback (most recent call last):
File "E:/Anaconda3/project/test/test.py", line 6, in <module>
from a_gu.a_gu import main -sharp a_gua_gucontent
File "E:\Anaconda3\project\test\a_gu\a_gu.py", line 427, in <module>
main(code)
NameError: name "code" is not defined