import csv
with open('csv.csv','r') as file:
reader = csv.reader(file)
比如这个 reader ,我要怎么才能查到它里面究竟是啥结构?
1
usnake OP print 显示
```<_csv.reader object at 0x00000210A7EFDEA0>``` help 显示: ```class reader(builtins.object) | CSV reader | | Reader objects are responsible for reading and parsing tabular data | in CSV format. | | Methods defined here: | | __iter__(self, /) | Implement iter(self). | | __next__(self, /) | Implement next(self). | | ---------------------------------------------------------------------- | Data descriptors defined here: | | dialect | | line_num``` ``` |
2
zk8802 2022-08-24 16:59:27 +08:00 via iPhone
print(dir(reader))
|
3
binge921 2022-08-24 17:12:16 +08:00
对象的内部结构 一般需要 ”脱掉“
|
4
kaiger 2022-08-24 17:52:19 +08:00
|
5
killva4624 2022-08-24 18:05:04 +08:00
看源码是最好的,去翻翻 csv. reader() 这个函数返回的对象。
|
6
treizeor 2022-08-24 18:05:06 +08:00
解剖?
|
7
yucongo 2022-08-25 12:25:05 +08:00 via Android
其实你要查的是 csv.reader:
help(csv.reader) |
8
julyclyde 2022-08-25 14:18:07 +08:00
dir
|