python字符串的乘法使用

 时间:2026-04-24 08:08:56

1、首先,我们要打开python软件,如图所示:

python字符串的乘法使用

python字符串的乘法使用

2、其次,我们要新建一个脚本来具体完成这个程序代码的存放:

python字符串的乘法使用

python字符串的乘法使用

3、我们新建的这个程序要完成的工作是:打印一个字符串长度大小的盒子,并且使字符串放置于盒子中间,重新把代码贴图如下:

sentence=raw_input('sentence:')

screen_width=80

text_width=len(sentence)

box_width=text_width+6

left_margin=(screen_width-box_width)//2

print

print '+ '+'-'*left_margin+'-'*(box_width+left_margin)+'+'

print ' '*left_margin+'|'+' '*text_width     +'|'

print ' '*left_margin+'|'+    sentence       +'|'

print ' '*left_margin+'|'+' '*text_width     +'|'

print '+ '+'-'*left_margin+'-'*(box_width+left_margin)+'+'

print

4、最后的运行效果如图(我们输入I miss you的字符串):

python字符串的乘法使用

  • 理财观念的重要性
  • 快速在公司站稳的5大秘诀,职场人必看
  • 如何用python的matplotlib画标准正态分布直方图
  • VMware如何彻底删除虚拟机
  • 如何使用python语言操作数据类型字典并展示数据
  • 热门搜索
    牙齿疼怎么办能快速不疼 怎么治疗灰指甲 顾家家居怎么样 荨麻疹怎么引起的 怎么样开淘宝网店 软通动力怎么样 爱奇艺怎么下载电视剧 贴膜怎么贴 怎么疏通毛孔 前锋热水器怎么样