python astype()_Python中的小语法

v2-f2e55cacf8feaee0d7b55b9265ac09c9_1440w.jpg?source=172ae18b
  1. type() / dtype() / astype()的区别
type()            返回参数的类型,比如“list,numpyndarray,tensor”
dtype()           返回数组中元素的类型,比如“int64,float64,complex64”
astype()          转换数据类型,比如“a = a.astype(int)将a数组内的元素转换为int类型”

2. python 异常输出美化工具

import pretty_errors

3. pytorch中的文件导入方式

  • 文件目录
--|
  • 场景1 main.py 要导入fileA.py中的fun1函数
方式1:不用__init__.py文件,在main.py中写
   from .packageA.fileA import fun1
方式2: 修改__init__.py文件,写入
    from .fileA import fun1
       在main.py中写
    from .packageA import fun1
类似通过__init__.py文件实现跨目录调用
 
  • 场景2 fileB.py 要导入fileA.py中的fun1函数
在fileB.py中写  
from ..packageA.fileA import fun1
  • 3
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值