zoukankan      html  css  js  c++  java
  • 75、python学习第一篇

    1、sys包下边的argv方法,从控制台获取数据

    '''
    Created on 2017年4月8日
    
    @author: weizhen
    '''
    import sys
    
    One = [" * ", "**", " * ", " * ", " * ", "***",'*********']
    Two = ["***", "*   *", "*  *", "  *", " * ", "***",'*********']
    Three = ["***", "*   *", "*  *", "  *", " * ", "***",'*********']
    Four = ["***", "*   *", "*  *", "  *", " * ", "***",'*********']
    Five = ["***", "*   *", "*  *", "  *", " * ", "***",'*********']
    Six = ["***", "*   *", "*  *", "  *", " * ", "***",'*********']
    Seven = ["***", "*   *", "*  *", "  *", " * ", "***",'*********']
    Eight = ["***", "*   *", "*  *", "  *", " * ", "***",'*********']
    Night = ["***", "*   *", "*  *", "  *", " * ", "***",'*********']
    Ten = ["***", "*   *", "*  *", "  *", " * ", "***",'*********']
    Digits = [One, Two, Three, Four, Five, Six, Seven, Eight, Night, Ten]
    try:
        digits = sys.argv[1]
        row = 0
        while row < 7:
            line = ""
            column = 0
            while column < len(digits):
                number = int(digits[column])
                digit = Digits[number]
                line += digit[row] + " "
                column += 1
                print(line+'in')
            print(line+'out')
            row += 1
    except IndexError:
        print("usage:bigdigits.py <number>")

    就是会判断输入值的大小,并根据控制台输入数组的大小去对字符串进行append

    这里要指出,line += digit[row] + " "这一行只是对字符串进行append,所有会用+=并不是对字符串进行连加

  • 相关阅读:
    gitio博客搭建,hexo + NeXT
    [MIsc]JD笔试编程题
    [MATH]Big Integer +
    【Math】GCD XOR 证明
    【Math】最近点对
    【SRM】600#div2 B 枚举
    【Game】组合游戏
    【Game】找出游戏必胜态
    【DP】树形DP 记忆化搜索
    141. Linked List Cycle
  • 原文地址:https://www.cnblogs.com/weizhen/p/6681418.html
Copyright © 2011-2022 走看看