找回密码
 立即注册

扫一扫,访问微社区

QQ登录

只需一步,快速开始

查看: 4231|回复: 2

[已回复] 为什么这里调用对象的方法不需要加小括号()?

2

主题

2

帖子

2

积分

贫民

积分
2
346669129 发表于 2017-1-20 11:27:02 | 显示全部楼层 |阅读模式
在openpyxl模块的官方文档中, 作者写的 rows() 应该是个方法吧? 有小括号的. 但是在代码中, 他又没加小括号来调用这个方法( 直接写了ws.rows), 看起来更像在调用一个属性,  这是怎么回事?

官方内容如下:
If you need to iterate through all the rows or columns of a file, you can instead use the openpyxl.worksheet.Worksheet.rows() property:

>>> ws = wb.active
>>> ws['C9'] = 'hello world'
>>> tuple(ws.rows)   
((<Cell Sheet.A1>, <Cell Sheet.B1>, <Cell Sheet.C1>),
(<Cell Sheet.A2>, <Cell Sheet.B2>, <Cell Sheet.C2>),
(<Cell Sheet.A3>, <Cell Sheet.B3>, <Cell Sheet.C3>),
(<Cell Sheet.A4>, <Cell Sheet.B4>, <Cell Sheet.C4>),
(<Cell Sheet.A5>, <Cell Sheet.B5>, <Cell Sheet.C5>),
(<Cell Sheet.A6>, <Cell Sheet.B6>, <Cell Sheet.C6>),
(<Cell Sheet.A7>, <Cell Sheet.B7>, <Cell Sheet.C7>),
(<Cell Sheet.A8>, <Cell Sheet.B8>, <Cell Sheet.C8>),
(<Cell Sheet.A9>, <Cell Sheet.B9>, <Cell Sheet.C9>))

2.jpg
回复

使用道具 举报

0

主题

3

帖子

3

积分

贫民

积分
3
life 发表于 2017-1-20 14:04:52 | 显示全部楼层
传的内存地址。
回复 支持 1 反对 0

使用道具 举报

1

主题

4

帖子

4

积分

贫民

积分
4
嘿嘿雷 发表于 2017-2-8 15:10:49 | 显示全部楼层
楼上正解
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

快速回复 返回顶部 返回列表