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

75、python学习第一篇-LMLPHP

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

05-08 08:28