欧美一区二区三区老妇人-欧美做爰猛烈大尺度电-99久久夜色精品国产亚洲a-亚洲福利视频一区二区

Python中定義函數(shù)時出現(xiàn)returnoutsidefunction報錯如何解決

Python中定義函數(shù)時出現(xiàn) return outside function報錯如何解決,針對這個問題,這篇文章詳細介紹了相對應(yīng)的分析和解答,希望可以幫助更多想解決這個問題的小伙伴找到更簡單易行的方法。

站在用戶的角度思考問題,與客戶深入溝通,找到新吳網(wǎng)站設(shè)計與新吳網(wǎng)站推廣的解決方案,憑借多年的經(jīng)驗,讓設(shè)計與互聯(lián)網(wǎng)技術(shù)結(jié)合,創(chuàng)造個性化、用戶體驗好的作品,建站類型包括:網(wǎng)站建設(shè)、網(wǎng)站制作、企業(yè)官網(wǎng)、英文網(wǎng)站、手機端網(wǎng)站、網(wǎng)站推廣、域名申請、虛擬主機、企業(yè)郵箱。業(yè)務(wù)覆蓋新吳地區(qū)。

在Python中定義函數(shù)時報錯 SyntaxError: 'return' outside function
>>> def testPass(cryptPass):
...     salt = cryptPass[0:2]
... dictFile = open('dictionary.txt', 'r')
  File "", line 3
    dictFile = open('dictionary.txt', 'r')
           ^
SyntaxError: invalid syntax
>>> for word in dictFile.readlines():
...     word = word.strip('\n')
...     cryptWord = crypt.crypt(word,salt)
...     if (cryptWord == cryptPass):
...         print "[+] Found Password: "+word+"\n"
...         return True
...     print "[-] Pasword Not Found.\n"
...     return False
... 
  File "", line 6
SyntaxError: 'return' outside function

報錯原因:
函數(shù)中的縮進格式有誤,第3行之后的縮進格式不正確

解決方法:
規(guī)范縮進格式
>>> def testPass(cryptPass):
...     salt = cryptPass[0:2]
...     dictFile = open('dictionary.txt', 'r')
...     for word in dictFile.readlines():
...         word = word.strip('\n')
...         cryptWord = crypt.crypt(word,salt)
...         if (cryptWord == cryptPass):
...             print "[+] Found Password: "+word+"\n"
...             return
...         print "[-] Pasword Not Found.\n"
...         return
... 

關(guān)于Python中定義函數(shù)時出現(xiàn) return outside function報錯如何解決問題的解答就分享到這里了,希望以上內(nèi)容可以對大家有一定的幫助,如果你還有很多疑惑沒有解開,可以關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道了解更多相關(guān)知識。

網(wǎng)站欄目:Python中定義函數(shù)時出現(xiàn)returnoutsidefunction報錯如何解決
分享路徑:http://chinadenli.net/article26/ppgojg.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供Google、外貿(mào)網(wǎng)站建設(shè)、網(wǎng)站設(shè)計公司、響應(yīng)式網(wǎng)站、App設(shè)計、動態(tài)網(wǎng)站

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

成都定制網(wǎng)站網(wǎng)頁設(shè)計