为什么python (\'请输入一个数:\')还没写完就已经编译完了?
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('请输入一个数:'))
这个是直接执行了,而不是让你再输入程序了
其他回答
暂无其它回答!