• 牛客网python代码编程模板


    牛客网的输入输出对于刚开始用的人来说肯定是个迷,本地跑结果是对的,但是牛客网却老是提示0%的通过率。这里总结一下牛客网使用python的编程模板:

    while True:
        try:
            num = input() # 单个数据输入
            nums = input().split() # 多行数据输入
            ...
            do_sth
        except:
            break
    

    有时候可能会遇到这种情况,即会不停的有输入数据,但是题目中也没有明确地说停止条件,那么默认就是输入为空的时候就停止输入,模板如下:

    inputs = []
    while True:
        try:
            num = input() 
            if num:
                inputs.append(num)
            else:
                break
        except:
            break
    
    do_sth
    
  • 相关阅读:
    初识jQuery(2)
    初识jQuery(1)
    document和javaScript内置对象
    location
    history
    window对象
    注释、语法约定、函数和作用域
    运算符和typeof
    string
    数据恢复
  • 原文地址:https://www.cnblogs.com/marsggbo/p/13301090.html
Copyright © 2020-2023  润新知