清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 | ''' print the "Hello, world!" on the console ''' import os ''' read data in file ''' class File: def __init__( self ): self .data = os.getcwd() + '\\data.txt' self .datalines = self .readDataToList() def readDataToList( self ): data = [] try : file = open( self .data, "r" ) data = file.readlines() finally : file.close() return data def getDataAtIndex( self ,num): return self .datalines[num] def getData( self ,nList): dataList = [] for i in nList: dataList.append( self .getDataAtIndex(i)) return dataList ''' get char index ''' class Index: def getIndexList(str): indexList = [] for x in list(str): indexList.append(ord(x) - 0x20 ) return indexList ''' print content ''' class MyPrint: ''' def myPrint(self,tup): for i in tup: forPrint = '' for j in range(8): if int(i,16)&(0x01<<j): #make every '1' into '*' forPrint = '*' + forPrint else: forPrint = ' ' + forPrint print(forPrint) ''' def getSingleByte( self ,str16): sByte = '' for i in range( 8 ): if int(str16, 16 )&( 0x01 <<i): sByte = '*' + sByte else : sByte = ' ' + sByte return sByte def concatOneLine( self ,matrix,lineNum): sLine = '' for data in matrix: sLine + = self .getSingleByte(data[lineNum]) return sLine def printInLine( self ,matrix): som = len(matrix) printLine = '' for i in range(len(matrix[ 0 ])): printLine + = self .concatOneLine(matrix,i) + '\n' print (printLine) ''' main ''' if __name__ = = '__main__' : content = input( '输入你想打印的内容(只限ASCII码可表示的内容——英文、数字和部分符号):\n' ) indexList = Index.getIndexList(content) file = File() matrix = [] for i in indexList: data = file.getDataAtIndex(i) matrix.append(data.split( ',' )) myPrint = MyPrint() myPrint.printInLine(matrix) os.system( 'pause' ) |