Skip to content

Instantly share code, notes, and snippets.

@ImSingee
Created May 8, 2018 06:17
Show Gist options
  • Save ImSingee/b7847d65d0e75809d769fca3d5a007e9 to your computer and use it in GitHub Desktop.
Save ImSingee/b7847d65d0e75809d769fca3d5a007e9 to your computer and use it in GitHub Desktop.
取出一段字符串前端的数字
def get_head_number(s):
m = ''
for i in s:
if i.isdigit():
m += i
else:
break
if m == '':
return None
else:
return int(m)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment