不是由于不正确的whitesp导致的Python缩进问题

2024-10-03 19:22:50 发布

您现在位置:Python中文网/ 问答频道 /正文

以下代码中出现缩进错误:

 28 def dropletExistsInSummaries( droplet ):                                                                                                                             
 29   """                                                                                                                                                                
 30   dropletExists() -- checks to see if a droplet's URL exists in the summary table, takes one argument                                                                
 31   * droplet is the DID of the raindrop                                                                                                                               
 32   """                                                                                                                                                                
 33   log.debug( "entering" )                                                                                                                                            
 34   c2 = db.cursor()                                                                                                                                                   
 35   d = ( droplet, )                                                                                                                                                   
 36   did = 0                                                                                                                                                            
 37   try:                                                                                                                                                               
 38     c2.execute( 'SELECT did from summaries where did = ?', d )                                                                                                       
 39     did = c2.fetchone()[0]                                                                                                                                           
 40   except Exception, e:                                                                                                                                               
 41     log.error( "dropletExists query failed: %s", e )                                                                                                                 
 42   if did > 0:                                                                                                                                                        
 43     return did                                                                                                                                                       
 44   else:                                                                                                                                                              
 45     return 0                                                                                                                                                         
 46                                                                                                                                                                      
 47                                                                                                                                                                      
 48 def summarizeDroplet( did, url ):                                                                                                                                    
 49   """                                                                                                                                                                
 50   TODO: document this                                                                                                                                                
:x                                                                                                                                                                      
sodaphish@svr-lnx02:~/semanticrss$ ./tst.py 
  File "./tst.py", line 37
    try: 
    ^
IndentationError: unexpected indent

…这对我来说没有任何意义,因为我已经检查了所有东西是否正确缩进了!我已经盯着这个看了好几个小时了,我不得不接受我需要帮助的事实

说实话,我不太清楚为什么我要在第35行用parens包围“droplet”,我猜这就是问题的原因,但我不能肯定地告诉你这个问题与此有关

作为记录,我使用的是python2.7.9

提前感谢您的帮助


Tags: the代码pylogreturnifdef错误