虽然写了很长时间,但是这个点一直非常模糊,每次为了省事都直接return
import scanpy as sc
a = 5
b = [1, 2, 3]
c = {'haha':789, 'hehe':456}
adata = sc.read_10x_mtx(
'../../data/SampleID_1_UM10/', # mtx 文件目录
cache=True)
print(id(a), id(b), id(c), id(adata))
print(f'b:{b}')
print(adata.obs)
def test(a, b, c, adata):
print('传参后')
print(id(a), id(b), id(c), id(adata))
b.append(123)
adata.obs['luna'] = 'May the moonlight light your way'
test(a, b, c, adata)
print(f'b:{b}')
print(adata.obs)
print(adata.obs['luna'])
输出:
140093769890224 140091746813632 140093769304704 140091745599392
b:[1, 2, 3]
Empty DataFrame
Columns: []
Index: [AAACCTGAGATGTAAC-1, AAACCTGCATCCCATC-1, AAACCTGGTGTGACGA-1, AAACCTGTCACGCATA-1, ...]
[5170 rows x 0 columns]
传参后
140093769890224 140091746813632 140093769304704 140091745599392
b:[1, 2, 3, 123]
luna
AAACCTGAGATGTAAC-1 May the moonlight light your way
AAACCTGCATCCCATC-1 May the moonlight light your way
AAACCTGGTGTGACGA-1 May the moonlight light your way
AAACCTGTCACGCATA-1 May the moonlight light your way
AAACCTGTCCAGATCA-1 May the moonlight light your way
... ...
TTTGTCACAGTAACGG-1 May the moonlight light your way
TTTGTCACATCACGAT-1 May the moonlight light your way
TTTGTCAGTAAGAGAG-1 May the moonlight light your way
TTTGTCAGTCGCCATG-1 May the moonlight light your way
TTTGTCAGTCTGGTCG-1 May the moonlight light your way
所以传参实际上是传递了地址,无需次次return