def Cal(sum = 100.0, cost = 12.0):
# sum是初始钱数,cost是每月开销
if sum <cost:
print "You don't have enough money in the begining!"
return
else:
month = 0
rest = sum + 0.0
print "培伏镇Month | Cost | Rest"
print " %.0f | %.2f | %.2f"%(month, cost, rest)
while sum >cost:
rest = sum - cost
month += 1
print " %.0f | %.2f | %.2f"%(month, cost, rest)
sum -= cost
print " %.0f | %.2f | 0.00"%(month+1, rest)
Cal()
# 我也是初学者,谬误百配粗出,见笑了。
-------------------------------------------------------
输出如下:
Month | Cost | Rest
0 | 12.00 | 100.00
1 | 12.00 | 88.00
2 | 12.00 | 76.00
3 | 12.00 | 64.00
4 | 12.00 | 52.00
5 | 12.00 | 40.00
6 | 12.00 | 28.00
7 | 12.00 | 16.00
8 | 12.00 | 4.00
9 | 4.00 | 0.00
n=10rmb=10000
nll=1.1
for i in range(1,n+1):
者局print 型渗rmb*nll**i , 卜嫌脊rmb*nll**i - rmb*nll**(i-1)
股票自动交易助手提供了一个 Python 自动下单接口,参考代码
#股票自动交易助手 Python 自动下单使用 例子#把此脚本和 StockOrderApi.py Order.dll 放到你自己编写敏岁的脚本同一目录
from StockOrderApi import *
#买入测试
#Buy(u"600000" , 100, 0, 1, 0)
#卖出测试,是持仓股才会有动作
#Sell(u"000100" , 100, 0, 1, 0)
#账户信息
print("股票自动交易接口测试")
print("账户信息")
print("--------------------------------")
arrAccountInfo 桥轿睁= ["总资产", "可用资金", "持仓总市值", "总盈利金额", "持仓数量"]
for i in range(0, len(arrAccountInfo)):
value = GetAccountInfo( u"" , i, 0)
print ("%s %f "%(arrAccountInfo[i], value))
print("--------------------------------")
print(" ")
print("股票持仓")
print("--------------------------------")
#取出所有的持仓股票代码,结果以 ','隔开的
allStockCode = GetAllPositionCode(0)
allStockCodeArray = allStockCode.split(',')
for i in range(0, len(allStockCodeArray)):
vol = GetPosInfo( allStockCodeArray[i] , 0 , 0)
changeP = GetPosInfo( allStockCodeArray[i] , 4 , 0)
print ("%s %d 帆袜%.2f%%"%(allStockCodeArray[i], vol, changeP))
print("--------------------------------")
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)