duration = inputScriptLine.split(' ', 1)[1]
if type(duration) == str:
print ' Error: Sleep duration "' + duration + '" is not numeric'
Run Code Online (Sandbox Code Playgroud)
给SLEEP 50我,我明白了Error: Sleep duration "50" is not numeric
我不太关心为什么,我只是想知道我如何编码以便SLEEP 50有效而SLEEP APNOEA不是.
使用isdigit():
if not duration.isdigit():
print 'Error: Sleep duration "' + duration + '" is not numeric'
Run Code Online (Sandbox Code Playgroud)
它会检查所有字符是否duration都是数字.
| 归档时间: |
|
| 查看次数: |
209 次 |
| 最近记录: |