def change(n):
    n[0] = 'Mr Gumby'

names = ['Mrs Entity', 'Mrs. Thing']
change(names)
print(names)

result:

['Mr Gumby', 'Mrs. Thing']

 

记住:字符串,数字, 元组是不可变的,即无法修改的。

相关文章:

  • 2021-08-15
  • 2021-12-07
  • 2022-02-21
  • 2021-08-22
  • 2022-01-22
  • 2021-06-15
  • 2021-10-02
  • 2023-04-04
猜你喜欢
  • 2021-08-27
  • 2022-12-23
  • 2021-12-02
  • 2022-12-23
  • 2021-08-04
  • 2022-12-23
  • 2021-12-18
相关资源
相似解决方案