python初学之helloworld,pythonhelloworld,'''print the
文章由Byrx.net分享于2019-03-23 05:03:04
python初学之helloworld,pythonhelloworld,'''print the
'''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')
相关内容
- 非utf8编码转换utf-8,utf8编码转换utf-8,strutf8 = te
- python下载百度音乐代码,python百度音乐代码,之前看到有
- Python获取系统信息的代码,python获取系统信息,import o
- # 根据比例求角度,,from math im
- python邮件发送,,None
- python使用sqlite3的简单代码,pythonsqlite3代码,#Filename: D
- Python使用剪切板代码,python剪切代码,此段代码可以利用
- python ftplib模块制作ftp客户端,pythonftplib,#!/usr/bin/p
- python验证文件是否可读可写,python验证文件可读,# Imp
- 九九乘法表,乘法,# 9*9for i i
评论关闭