-1
def displayChar(d):
if d.isalpha():
print(d, "is a str")
elif a.isdigit():
if 'float' in str(type(eval(d))):
print(d, "is a float")
else:
print(d, "is a int")
else:
print("Your input is not allowed")
del d
a = input('Enter the first word : ')
b = input('Enter the second word : ')
displayChar(a)
displayChar(b)
之間輸出的問題沒有得到想要的輸出話說Python編程 - 每個函數調用
A is a str
1 is a int
,而不是「1是INT」的輸出 能收到一些解釋我好嗎?
C:\Python34\python.exe C:/Users/Suresh/PycharmProjects/Examples/func1.py
Enter the first word : A
Enter the second word : 1
A is a str
Your input is not allowed
Process finished with exit code 0
這是執行或調試這是題外話上Programmers.SE的問題。本網站重點介紹[幫助/在線主題]中介紹的概念設計和體系結構問題。 –
'elif a.isdigit():'應該是'elif d.isdigit():' –