python 几个特别点

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

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 = True
f = False
print(type(t)) # Prints ""
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 formatting
print(hw12)  # prints "hello world 12"

 

 

 

 

 

你可能感兴趣的:(python 几个特别点)