2016-04-03 23 views
0

這是荒謬的,我想不通這是爲什麼不工作...獲取縮進錯誤與Python 3印刷

def main(): 
    """Shows basic usage of the Gmail API. 

    Creates a Gmail API service object and outputs a list of label names 
    of the user's Gmail account. 
    """ 

    credentials = get_credentials() 
    http = credentials.authorize(httplib2.Http()) 
    service = discovery.build('gmail', 'v1', http=http) 

    results = ListThreadsMatchingQuery(service, EMAIL_LOGIN, '[email protected]') ## searching based on email 
    print(len(results)) 

我得到的錯誤:

$ python quickstart1.py 
    File "quickstart1.py", line 155 
    print(len(results)) 
    ^
IndentationError: unexpected indent 

什麼我做錯了嗎

+0

我建議複製粘貼此代碼,因爲此代碼不會引發該錯誤。 – idjaw

+0

我做了複製/粘貼! –

+1

我的意思是將這個問題中的代碼複製回你的編輯器並運行它。因爲我複製粘貼,我不能重新產生你的問題。 – idjaw

回答

0

你不能在Python代碼中使用4個空格和表格縮進它們,下次用4個空格縮進設置你的編輯器

+0

yup!就是這樣,謝謝。 –

+0

@MorganAllen:另外,檢查你是否真的在Python 3上。Python 3可能會給你一個不同的,更多的信息錯誤。 – user2357112