我對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