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 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?
  • ¥15 matlab(相关搜索:紧聚焦)
  • ¥15 基于51单片机的厨房煤气泄露检测报警系统设计
  • ¥15 路易威登官网 里边的参数逆向
  • ¥15 Arduino无法同时连接多个hx711模块,如何解决?
  • ¥50 需求一个up主付费课程