为什么python (\'请输入一个数:\')还没写完就已经编译完了?

原问题:为什么python (\'请输入一个数:\')还没写完就已经编译完了?
分类:编程开发 > 最后更新时间:【2017-07-28 14:36:36】
问题补充:

Python 3.6.0 (v3.6.0:41df79263a11, Dec 23 2016, 07:18:10) [MSC v.1900 32 bit (Intel)] on win32Type "copyright", "credits" or "license()" for more information.>>> def showMaxFactor(num)SyntaxError: invalid syntax>>> def showMaxFactor(num):count=num//2while count>1:if num%count==0:print('%d最大的约数是%d' %(num,count))breakcount-=1else: print('%d是素数!'%num)

>>> num=int(input('请输入一个数:'))请输入一个数:showMaxFactor(num)Traceback (most recent call last): File "<pyshell#11>", line 1, in <module> num=int(input('请输入一个数:'))ValueError: invalid literal for int() with base 10: ''>>>

最佳答案

一,不要在命令行模式下直接编程序,你可以先用文本编辑器或开发工具来写程序

二.你的函数定义已结束

num=int(input('请输入一个数:'))

这个是直接执行了,而不是让你再输入程序了

最佳答案由网友  whoami1978  提供
公告: 为响应国家净网行动,部分内容已经删除,感谢网友理解。
10

分享到:

其他回答

暂无其它回答!