我在使用Python匹配字符串中的数字时遇到了问题,应该清楚地匹配它.它甚至不匹配[0-9] [\d]或仅仅是0一个人.我的疏忽在哪里?
import re
file_without_extension = "/test/folder/something/file_0"
if re.match("[\d]+$", file_without_extension):
print "file matched!"
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2898 次 |
| 最近记录: |