Python 金融进阶
Kennedy Behrman
Data Engineer, Author, Founder
trns = { 'symbol': 'TSLA', 'type':'BUY', 'amount': 300}
print(trns['amount'])
300
复合语句
语句 1
语句 2
语句 3
if <expression> :
if x < y:
if x in y:
if x and y:
if x:
if <expression>:
statement
statement
statement
if <expression>: statement;statement;statement
trns = { 'symbol': 'TSLA', 'type':'BUY', 'amount': 300}
if trns['type'] == 'SELL':
print(trns['amount'])
trns['type'] == 'SELL'
False
trns = { 'symbol': 'APPL', 'type':'SELL', 'amount': 200}
if trns['type'] == 'SELL':
print(trns['amount'])
200
if x in y:
print("在 y 中找到 x")
else:
print("y 中没有 x")
if x == y:
print("相等")
elif x < y:
print("更小")
if x == y:
print("相等")
elif x < y:
print("更小")
elif x > y:
print("更大")
elif x == 0
print("零")
if x == y:
print("相等")
elif x < y:
print("更小")
elif x > y:
print("更大")
elif x == 0
print("零")
else:
print("以上皆非")
Python 金融进阶