鱼C论坛

 找回密码
 立即注册
查看: 2390|回复: 3

在python3.5.3中运行不了 好心鱼油帮忙看下有哪些错误

[复制链接]
发表于 2017-3-22 11:31:41 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
sentence=input("Sentence:")
Sentence:He's a very naughty boy
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-2)+'+')
print(''*left_margin+'|'+' '*text_width   +'|')
print(''*left_margin+'|'+    sentence     +'|')
print(''*left_margin+'|'+' ' text_width   +'|')
print(''*left_margin+'+'+'-'*(box_width-2)+'+')
print(                                        )
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2017-3-22 11:47:29 | 显示全部楼层
1.Sentence:He's a very naughty boy 这一句是什么莫名其妙的,没见过python这种语法
2.第5句print的text_width少了*号吧
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2017-3-22 16:58:11 | 显示全部楼层

  1. sentence=input("Sentence:")
  2. Sentence:He's a very naughty boy
  3. screen_width=80
  4. text_width=len(sentence)
  5. box_width=text_width+6
  6. left_margin=(screen_width-box_width)//2
  7. print(                                        )
  8. print(''*left_margin+'+'+'-'*(box_width-2)+'+')
  9. print(''*left_margin+'|'+' '*text_width   +'|')
  10. print(''*left_margin+'|'+    sentence     +'|')
  11. print(''*left_margin+'|'+' ' *text_width   +'|')
  12. print(''*left_margin+'+'+'-'*(box_width-2)+'+')
  13. print(                                        )
复制代码


你的第二行是你的输入吧
如果不是,如果就在你的代码中
请删掉
然后改完代码后运行
在 input 里输入 He's a very naughty boy
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2017-3-22 17:25:48 | 显示全部楼层
首先 吐槽下。。。以后别这样发代码。。。。
--------------------------------------分割线---------------------------------------------------------------------
你说的不能执行是不是你在idle里面不能执行,且会显示“SyntaxError: multiple statements found while compiling a single statement”的错误?然后你说不能执行,是不是这个意思?
解决这个问题的办法,就是建一个py文件,把代码放进去,然后就可以执行了:
代码如下:
  1. sentence=input("Sentence:")
  2. screen_width=80
  3. text_width=len(sentence)
  4. box_width=text_width+6
  5. left_margin=(screen_width-box_width)//2
  6. print(                                        )
  7. print(''*left_margin+'+'+'-'*(box_width-2)+'+')
  8. print(''*left_margin+'|'+' '*text_width   +'|')
  9. print(''*left_margin+'|'+    sentence     +'|')
  10. print(''*left_margin+'|'+' '*text_width   +'|')
  11. print(''*left_margin+'+'+'-'*(box_width-2)+'+')
  12. print(                                        )
复制代码

这样点击run,就可以运行啦;你的代码有点小错误,帮你改了下。。。就是倒数第三个print,text_width前面少了*号。
下面试运行结果,看下是不是你想要的。。。。
搜狗截图17年03月22日1721_1.png 搜狗截图17年03月22日1723_2.png 搜狗截图17年03月22日1724_3.png
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2025-5-13 07:20

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表