网络编程
位置:首页>> 网络编程>> Python编程>> python3.3实现乘法表示例

python3.3实现乘法表示例

  发布时间:2023-11-01 11:06:55 

标签:python3,乘法


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实现乘法表示例
 

0
投稿

猜你喜欢

手机版 网络编程 asp之家 www.aspxhome.com