手机
当前位置:查字典教程网 >脚本专栏 >python >python3.3实现乘法表示例
python3.3实现乘法表示例
摘要:复制代码代码如下:fromStringHelperimportPadLeftforxinrange(1,10):foryinrange(1,...

复制代码 代码如下:

from StringHelper import PadLeft

for x in range(1,10):

for y in range (1,x+1):

endflag=' | n' if x==y else ' | '

print(y,'*',x,'=',PadLeft( str(x*y),2,' '),end=endflag)

StringHelper.py

复制代码 代码如下:

# -*- coding: utf8 -*-

'''

扩展为C#中的String.PadLeft

'''

def PadLeft(str, num, padstr):

stringlength = len(str)

n = num - stringlength

if n >= 0:

str = padstr*n + str

return str

效果图:

python3.3实现乘法表示例1

【python3.3实现乘法表示例】相关文章:

Python实现端口复用实例代码

基于Python实现的扫雷游戏实例代码

python连接池实现示例程序

Python实现全局变量的两个解决方法

采用python实现简单QQ单用户机器人的方法

python重试装饰器示例

python33 urllib2使用方法细节讲解

wxpython学习笔记(推荐查看)

python实现ip查询示例

python合并文本文件示例

精品推荐
分类导航