python 基础
_卷心菜_
一只努力鸭!
展开
-
python获取文件中的任意一行数据
import randomwith open("文件地址") as f: data = f.readlines() for i in random.sample(data,1): print i原创 2022-01-10 22:07:07 · 502 阅读 · 0 评论 -
pip和conda批量导出环境组件requirements.txt
pip freeze > requirements.txtconda env export > environment.yml原创 2021-12-14 11:16:32 · 412 阅读 · 0 评论 -
np.linspace
np.linspace用法介绍:点击举例1:ret = np.linspace(1, 10, 10)print(ret)[ 1. 2. 3. 4. 5. 6. 7. 8. 9. 10.]举例2:ret = np.linspace(1, 10, 10) / 2print(ret)[0.5 1. 1.5 2. 2.5 3. 3.5 4. 4.5 5. ]结果为例子1结果中的每个数值除以2。...原创 2021-11-09 09:37:50 · 446 阅读 · 0 评论 -
os.path.abspath()和os.path.dirname()
os.path.abspath()作用:返回绝对路径import osif __name__ == '__main__': path1 = os.path.abspath(__file__) print(path1)输出当前代码所在的绝对路径:D:\anaconda\envs\pytorch\python.exe E:/pycharm/word/others/test.pyE:\pycharm\word\others\test.pyProcess finished wit原创 2021-07-08 22:30:35 · 609 阅读 · 0 评论