joeSwan :
how can I check in python if string is in correct format?
I have variable tag, and it should be in fomrat 0.0
e.g
tag = "1.0"
if tag != (is not in format **0.0**):
print("not in tag")"
else:
print("correct tag")"
In bash it looks like this
tag="10.0"
if [[ $tag != "${tag%.*}.${tag#*.}" ]]; then
echo "wrong tag"
fi
DYZ :
The simplest implementation is to use regular expressions:
if not re.search("^\d+\.\d+$", tag):
#does not match
Guess you like
Origin http://43.154.161.224:23101/article/api/json?id=360504&siteId=1