Python: Difference between revisions

 
(One intermediate revision by the same user not shown)
Line 67: Line 67:
# Format to two decimal places
# Format to two decimal places
print(f"Accuracy: {accuracy:.02f}%")
print(f"Accuracy: {accuracy:.02f}%")
# Format an int to 2 digits
print(f"Size: {size:02}%")
</syntaxhighlight>
</syntaxhighlight>


Line 178: Line 181:
import re
import re
my_regex = re.compile(r'height:(\d+)cm')
my_regex = re.compile(r'height:(\d+)cm')
my_match = myReg.match("height:33cm");
my_match = my_regex.match("height:33cm");
print(my_match[1])
print(my_match[1])
# 33
# 33