python的其他知识

1.帮助

dir()和help()

import torch
dir(torch.cuda) #查看torch.cuda下有那些东西
help(torch.cuda.is_available) # 查看torch.cuda.is_available的使用

2.__call__()

__call__()的功能类似于在类中重载 () 运算符,使得类实例对象可以像调用普通函数那样,以“对象名()”的形式使用。
参考:链接

3.items()
Python 字典(Dictionary) items() 函数以列表返回可遍历的(键, 值) 元组数组。

posted @ 2022-07-26 19:51  好人~  阅读(16)  评论(0)    收藏  举报