2017-02-13 214 views
-4

即时得到错误的植酮PROGRAMM我尝试运行,我不真的明白,帮助将不胜感激:Python代码混淆

import hashlib, urlib, re 
def convert2swissgrid(value, num1, num2, num3): 
    return value * num1 + value + (value/num2) - num3 
web_domain = 'http://gc6ynbd.hikiashi.ch/' 
web_page = '/index.html' 
web_directory = hashlib.md5(raw_input('Please enter code: ')).hexdigest() 
url = web_domain + web_directory + web_page 
web_html = urllib.urlopen(url).read() 
web_body = str(re.findall('<body>((.|n)*)</body>', web_html)).split()  
hex_values, dec_values = list(), list() 
for value in web_body: 
    if re.search('^[0-9A-F]{,}[0-9A-F]$', value): 
     hex_values.append(value[::-1]) 
     if len(hex_values[-1]) > 2: 
      dec_values.append(int(hex_values[-1], 6))    
north, east = 0, 0 
for value in dec_values 
north = north + value % 47 
east = east + value % 8  
print "Norden:", convert2swissgrid(east, len(str(dec_values[4075]), len(str(dec_values[429])), dec_values[1838] - dec_values[134]) 
print "Osten:", convert2swissgrid(north, len(str(dec_values[54])), len(str(dec_values[1684])), dec_values[1732] - dec_values[2660]) 

它显示我是在第21行,在dec_values值的误差 该消息是:

SyntaxError: invalid syntax                                          sh-4.3$ python main.py                                                       
    File "main.py", line 22                                                      
    for value in dec_values 

有人可以帮我吗?

+1

您在'for'行的结尾需要一个冒号,你需要后至少一个缩进线。 – khelwood

+0

这一行缺少一个冒号(应该是'dec_values中的值:')。下面的一些行的缩进也是错误的。多少行?这取决于你正在尝试做什么。 –

+0

用于在dec_values中为值更新的行'用于在dec_values中的值:' –

回答

2

这应该工作:

for value in dec_values: 
    north = north + value % 47 
    east = east + value % 8