table of Contents:
1. Find all numbers (python find digits in string) string
2. python generating continuous floating-point (e.g., 0.1, 0.2, 0.3, 0.4, ..., 0.9) (python range () for floats)
content:
1. Find all numbers (python find digits in string) string
method 1:
https://stackoverflow.com/questions/12005558/python-find-digits-in-a-string
name = 'body_flaw_validate_set20191119170917_'
list(filter(str.isdigit, name))
['2', '0', '1', '9', '1', '1', '1', '9', '1', '7', '0', '9', '1', '7']
Method 2:
https://www.geeksforgeeks.org/python-extract-digits-from-given-string/
import re
name = 'body_flaw_validate_set20191119170917_'
re.sub("\D", "", name)
'20191119170917'
2. python generating continuous floating-point (e.g., 0.1, 0.2, 0.3, 0.4, ..., 0.9) python range () for floats
https://stackoverflow.com/questions/7267226/range-for-floats
method 1:
[x / 10.0 for x in range(1, 10)]
[0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9]
Method 2:
import pylab as pl
pl.frange(0.1,0.9,0.1)
array([0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9])
Method 3:
import numpy
numpy.linspace(0.1, 0.9, num=9)
array([0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9])
3.