Opengist

Explore

  • All gists
  • Topics
  • Users
Give feedback on the new UI Powered by Opengist ⋅ 144ms

user:thomas gists created by user

title:mygist gists with given title

description:sync gists with given description

filename:myfile.txt gists having files with given name

extension:yml gists having files with given extension

language:go gists having files with given language

topic:homelab gists with given topic

all:systemctl search all fields

Login
l

list-unpacking

Recently created Least recently created Recently updated Least recently updated

timmy / Python 參數解包 (*args 和 **kwargs)

Last active 6 hours ago argument-unpacking assert dictionary-unpacking function-arguments list-unpacking python

這段 Python 程式碼 展示了 參數解包 (Argument Unpacking) 的應用方式,包括 列表解包 (*args) 和 字典解包 (**kwargs),用於函式呼叫時動態傳遞參數。

0 0 0 1
1 assert list(range(3, 6)) == [3, 4, 5]
2
3 arguments_list = [3, 6]
4 assert list(range(*arguments_list)) == [3, 4, 5]
5
6
7 def function_that_receives_names_arguments(first_word, second_word):
8 return first_word + ", " + second_word + "!"
9