我对Python比较陌生。我想提出一个基本的程序,可以找出参数是否在函数中有一个整数。我不知道该把什么放入空白处。我通常不使用if/in类型配对。该功能的基础是这样的:Python - 确定参数是否是整数
def is_number(char):
if (somethinghere) in (somethinghere):
return True
else:
return False
结果应该是:
is_number('4')
True
is_number('nothing')
False
通常情况下,您只需要在(somethinghere)处写入'return(somethinghere)',而不是使用'if'语句和布尔文字。 – chepner 2014-09-24 01:48:21