dongfuguo 2017-01-02 03:03 采纳率: 100%
浏览 2594
已采纳

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.

  • 写回答

4条回答

  • threenewbee 2017-01-02 10:47
    关注

    可变参数个数,后面可以跟任意个数的数字

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog
  • ¥15 Excel发现不可读取的内容
  • ¥15 关于#stm32#的问题:CANOpen的PDO同步传输问题