程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 更多編程語言 >> 編程解疑 >> python-Python函數參數列表最後的斜線是干啥的?

python-Python函數參數列表最後的斜線是干啥的?

編輯:編程解疑
Python函數參數列表最後的斜線是干啥的?

很多Python函數或者類的方法中,幫助文檔都顯示最後有一個斜線,但是自己定義函數時卻不允許這樣用,請問這個斜線的作用是什麼呢?

help(sum)
Help on built-in function sum in module builtins:

sum(iterable, start=0, /)
Return the sum of a 'start' value (default: 0) plus an iterable of numbers

When the iterable is empty, return the start value.
This function is intended specifically for use with numeric values and may
reject non-numeric types.
>>> help(id)

Help on built-in function id in module builtins:

id(obj, /)
Return the identity of an object.

This is guaranteed to be unique among simultaneously existing objects.
(CPython uses the object's memory address.)

help(input)
Help on built-in function input in module builtins:

input(prompt=None, /)
Read a string from standard input. The trailing newline is stripped.

The prompt string, if given, is printed to standard output without a
trailing newline before reading input.

If the user hits EOF (*nix: Ctrl-D, Windows: Ctrl-Z+Return), raise EOFError.
On *nix systems, readline is used if available.
>>> help(filter)

Help on class filter in module builtins:

class filter(object)
| filter(function or None, iterable) --> filter object
|

| Return an iterator yielding those items of iterable for which function(item)
| is true. If function is None, return the items that are true.
|

| Methods defined here:
|

| getattribute(self, name, /)
| Return getattr(self, name).
|

| iter(self, /)
| Implement iter(self).
|

| new(*args, **kwargs) from builtins.type
| Create and return a new object. See help(type) for accurate signature.
|

| next(self, /)
| Implement next(self).
|

| reduce(...)
| Return state information for pickling.

最佳回答:


可變參數個數,後面可以跟任意個數的數字

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved