我玩python 2.7.这是我的问题:
>>> bra=[]
>>> put=['a','t']
>>> bra.append(put)
>>> bra
[['a', 't']]
>>> bra.append(put)
>>> bra
[['a', 't'], ['a', 't']]
>>> bra.append(put.reverse())
>>> bra
[['t', 'a'], ['t', 'a'], None]
Run Code Online (Sandbox Code Playgroud)
我的问题是:为什么de python解释器在最后一行给出结果,而不是:
[['a', 't'], ['a', 't'], ['t', 'a']]
Run Code Online (Sandbox Code Playgroud)
或者我怎样才能得到这个结果?
例如,我有一个参考编号a = 15
和b= 3
.
x=2
,f(a,b,x) = 1
因为如果将15分成3部分,则数字2在第一部分中.x=7
,f(a,b,x) = 2
因为如果将15分成3部分,则数字7在第二部分中.x=15
,f(a,b,x) = 3
因为如果将15分成3部分,则数字15在第3部分中.有这样的内置功能吗?