There were no trinocular operators before Python 2.5x, but with the development of language, three mesh operators were added after 2.5
1 " "2 here the main three-mesh operator3 It is also possible to quickly declare variables and assign values to variables by x,y=4,5 this way. 4 " "5x,y=4,56 ifx<y:7Small=x8 Else:9Small=yTen Print(small) One A - Print("after the-----is changed to the three mesh operator----") -Small=xifX<yElsey the Print(small)
Sometimes we in the development process, the program will be running when the possibility of a false pre-judgment, then we use what method to pre-judgment, this time we use the Assert this function, its role is, when the pre-judgment after the establishment, then run, if not, throw an exception.
1 " " 2 simple usage of assert 3 " " 4 a,b=3,65assert a>b6print(" performed ")
We judge A>b after the assert, but we can see by the assignment that it is not true, and this time the assert throws an exception:
Traceback (most recent): " e:/python/day-1/three mesh. PY " in <module> b=3.6Typeerror:cannot Unpack non-iterable Float Object
But if the conditions in the assert change to B>a, then the program prints "executed."
Python fifth day, two knowledge points three mesh operator and assert throw exception handling.