2
当我运行下面的代码时,弹出以下消息框。为什么它在我不想要的地方打印那些恼人的大括号?我正在使用Python 2.7和EasyGui。为什么Python在这里打印大括号?
from __future__ import division
from easygui import *
import ystockquote
def main():
PRHSX_message()
def PRHSX_message():
prhsx_share_price = float(ystockquote.get_last_trade_price('PRHSX'))
prhsx_daily_change = ystockquote.get_change('PRHSX')
prhsx_total_shares = 47.527
prhsx_starting_value = 2500
prhsx_percent_change = (((prhsx_share_price * prhsx_total_shares)/prhsx_starting_value) - 1) * 100
prhsx_percent_change = str("%.2f" % prhsx_percent_change) + "%"
prhsx_current_value = prhsx_share_price * prhsx_total_shares
prhsx_profit = prhsx_current_value - prhsx_starting_value
prhsx_current_value = "$" + str("%.2f" % prhsx_current_value)
prhsx_profit = "$" + str("%.2f" % prhsx_profit)
prhsx_string = "T. Rowe Price Roth IRA Account\n____________________________\n \
\nPercent Change:", str(prhsx_daily_change), \
"\nShare Price:", prhsx_share_price, \
"\nCurrent Value:", prhsx_current_value, \
"\nPercent Growth:", prhsx_percent_change, \
"\nProfit:", prhsx_profit
return msgbox(prhsx_string)
if __name__ == '__main__':
main()
你忘了.02的精度;) – ThiefMaster
@ThiefMaster:我没有改变原来的任务;我现在已经做到了。 –
啊。无论如何,现在你有'prhsx_current_value = prhsx_current_value'这似乎没有多大意义:p – ThiefMaster