Python 如何在多个字符串中插入内容?

Python 如何在多个字符串中插入内容?,python,string,numpy,jupyter,Python,String,Numpy,Jupyter,我有12个不同的字符串,它们是我想要的元组格式,因为我稍后将在图形中使用这些字符串。 如何将相同的字符串添加到字符串数组中 我有以下几个月: 一月、二月等,我想在每个字符串中插入“一月LSD”、“二月LSD”等 我尝试了此操作,但出现了一个错误: insert = 'LSDS' month_names = ('January {}', 'February {}','March {}','April {}', 'May {}', 'June {}', 'July {}', 'August {}'

我有12个不同的字符串,它们是我想要的元组格式,因为我稍后将在图形中使用这些字符串。 如何将相同的字符串添加到字符串数组中

我有以下几个月: 一月、二月等,我想在每个字符串中插入“一月LSD”、“二月LSD”等

我尝试了此操作,但出现了一个错误:

insert = 'LSDS'

month_names = ('January {}', 'February {}','March {}','April {}', 'May {}', 'June {}', 'July {}', 'August {}', 'September {}', 'October {}', 'November {}', 'December {}').format(insert)

print(month_names)

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-167-c79c038f3ebc> in <module>
      3 insert = 'LSDS'
      4 
----> 5 month_names = ('January {}', 'February {}','March {}','April {}', 'May {}', 'June {}', 'July {}', 'August {}', 'September {}', 'October {}', 'November {}', 'December {}').format(insert)
      6 
      7 print(month_names)

AttributeError: 'tuple' object has no attribute 'format'
insert='LSDS'
月份名称=(‘一月’、‘二月’、‘三月’、‘四月’、‘五月’、‘六月’、‘七月’、‘八月’、‘九月’、‘十月’、‘十一月’、‘十二月’)
打印(月份名称)
---------------------------------------------------------------------------
AttributeError回溯(最近一次呼叫上次)
在里面
3 insert='LSDS'
4.
---->5个月的名称=('一月{}、'二月{}、'三月{}、'四月{}、'五月{}、'六月{}、'七月{}、'八月{}、'九月{}、'十月{}、'十一月{}、'十二月{})。格式(插入)
6.
7打印(月份名称)
AttributeError:“元组”对象没有属性“格式”
inserted = [month.format(insert) for month in month_names]