【发布时间】:2014-06-05 21:53:54
【问题描述】:
我目前正在尝试使用变量在三引号字符串中进行连接。解决这个问题的最佳方法是什么?
print('''
Points left to spend: ''' + str(pointsLeft) + '''
''' + str(attrChoice) + ':\t' + '''[''' + str(charAttr[attrChoice]) + ''']
To reduce the number of points spent on this skill, simply enter a negative number.
'''
)
我得到的错误信息是:关键字不能是表达式。谁能解释这意味着什么以及是否有可能尝试这种连接?
【问题讨论】:
-
attrChoice、charAttr等是什么?
标签: python syntax-error concatenation string-interpolation