python传参传的是什么

虽然写了很长时间,但是这个点一直非常模糊,每次为了省事都直接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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值