python 几个特别点

来源:互联网 发布:用js给input赋值 编辑:程序博客网 时间:2024/05/02 04:23

原文链接,仅从中选取几个注意点

1.Note that unlike many languages, Python does not have unary increment (x++) or decrement (x--) operators.


2.Booleans: Python implements all of the usual operators for Boolean logic, but uses English words rather than symbols (&&||, etc.):


t = Truef = Falseprint(type(t)) # Prints "<class 'bool'>"print(t and f) # Logical AND; prints "False"print(t or f)  # Logical OR; prints "True"print(not t)   # Logical NOT; prints "False"print(t != f)  # Logical XOR; prints "True"

hw12 = '%s %s %d' % (hello, world, 12)  # sprintf style string formattingprint(hw12)  # prints "hello world 12"


原创粉丝点击