2018年1月10日 星期三

Python: Check if a string is numeric

Python: Check if a string is numeric

Python Basic: Exercise-95 with Solution

Write a Python program to check if a string is numeric.
Sample Solution:-
#str = 'a123'
#str = '123'
str=input("please input a string : ")
try:
    i = float(str)
except (ValueError, TypeError):
    print('\nNot numeric')
print()

================= RESTART: F:/Python_APSC/py-ex-basic-95.py =================
please input a string : a123

Not numeric

>>> 

沒有留言:

張貼留言

Fultter APP控制 WOKWI ESP32 RFID+LED (使用flutter_windows_3.19.1-stable Visual studio 1.108.2 )

Fultter APP控制 WOKWI ESP32 RFID+LED (使用flutter_windows_3.19.1-stable  Visual studio  1.108.2 ) 1) Android studio 環境設定 2) Visual studio  1.108...