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,所有会用+=并不是对字符串进行连加

  • 相关阅读:
    平衡二叉树之RB树
    平衡二叉树之AVL树
    实现哈希表
    LeetCode Median of Two Sorted Arrays
    LeetCode Minimum Window Substring
    LeetCode Interleaving String
    LeetCode Regular Expression Matching
    PAT 1087 All Roads Lead to Rome
    PAT 1086 Tree Traversals Again
    LeetCode Longest Palindromic Substring
  • 原文地址:https://www.cnblogs.com/weizhen/p/6681418.html
Copyright © 2011-2022 走看看