为什么此代码输出语法错误? (蟒蛇)

时间:2018-08-06 22:15:28

标签: python

from random import randint as random

names = ['Ninja','xXx_leet1337_xXx','robert87','nic0','y2ih8','roxky','Wierdio','a3rt','BeastyBoy','bobby']
active_players = names

deaths = (' shotgunned ', ' sniped ', ' ran over ', ' rifled ')

def findDeath():
    current_death = deaths[random(0,3)

while len(active_players) >= 2:
findDeath()
if current_death = ' sniped ':
    sniper_length = str(random(5,100))+ 'm'
    print(active_players[random(0,9)]+' '+current_death+'from '+sniper_length)
else:
    print(active_players)

输出:   文件“ .. \ Playground \”,第11行     当len(active_players)> = 2时:         ^ SyntaxError:语法无效

为什么?

1 个答案:

答案 0 :(得分:1)

您忘记关闭上一行的语句:

func uploadImageToFirebaseStorage(data: Data, onSuccess: @escaping (_ 
imageUrl: String) -> Void) {
let photoIdString = NSUUID().uuidString
let storageRef = Storage.storage().reference(forURL: 
Config.STORAGE_REF_URL).child(POST_REF).child(photoIdString)


storageRef.putData(data, metadata: nil) { (metadata, error) in
    if let error = error {
        debugPrint(error.localizedDescription)
        return
    }

    metadata?.storageReference?.downloadURL(completion: { (url, error) 
in
        if let error = error {
            print(error.localizedDescription)
            return
        }
        onSuccess("\(url!)")
    })
}
}

应该是

current_death = deaths[random(0,3)

始终在发生语法错误的位置之前进行检查:)

相关问题