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 Python爬取指定微博话题下的内容,保存为txt
  • ¥15 vue2登录调用后端接口如何实现
  • ¥65 永磁型步进电机PID算法
  • ¥15 sqlite 附加(attach database)加密数据库时,返回26是什么原因呢?
  • ¥88 找成都本地经验丰富懂小程序开发的技术大咖
  • ¥15 如何处理复杂数据表格的除法运算
  • ¥15 如何用stc8h1k08的片子做485数据透传的功能?(关键词-串口)
  • ¥15 有兄弟姐妹会用word插图功能制作类似citespace的图片吗?
  • ¥15 latex怎么处理论文引理引用参考文献
  • ¥15 请教:如何用postman调用本地虚拟机区块链接上的合约?