Python笔记
杂项
列表遍历
1 2 3 4 5
| for i in range(1,10,2)
for i in np.arrange(0,1,0.01) for i in np.linspace(0,0.9,10)
|
查看gpu情况
绘图
matpltlib

matplotlib是一个最大的绘图库,包括了pyplot、pylaib等基础绘图库。
1
| import matplotlib.pyplot as plt
|
1 2
| plt.title("title") plt.rcParams['font.sans-serif']=['SimHei']
|
1 2 3
| plt.figure(figsize=(6, 3)) plt.plot(6, 3) plt.plot(3, 3 * 2)
|
1 2 3 4 5
| plt.xlim(0,6) plt.ylim((0, 3)) plt.xlabel('X') plt.ylabel('Y') plt.rcParams['axes.unicode_minus']=False
|
1
| plt.annotate(text='标记点',xy=(3,np.sin(3)),xytext=(4,-0.5),weight='bold',color='b',arrowprops=dict(arrowstyle='-|>',color='k'))
|
git
基本步骤
-
添加公钥:everything搜索id_rsa.pub
,复制其中内容到github/gitee
-
克隆仓库到本地
1
| git clone https://gitee.com/momaoto/fourth-assignment.git
|
-
进入文件夹初始化仓库
-
关联远程仓库
1 2 3
| git remote add origin https://gitee.com/momaoto/fourth-assignment.git git remote rm origin git remote -v
|
origin为后面链接所指远程库的别名,方便操作
-
拉取远程分支与本地仓库合并
1
| git pull origin master:main
|
-
代码添加进本地暂存区
1 2
| git add . git add test.txt
|
-
确认提交记录到本地仓库
1 2
| git commit . git commit test.txt
|
- 安装子模块
1 2 3
| git submodule init git submodule update
|
命令大全
1 2 3 4 5 6 7
| git remote:不带任何参数直接运行 git remote,将会列出当前仓库中已经配置的远程仓库的简写名称列表。 git remote -v:显示当前仓库中已经配置的远程仓库的简写名称和对应的URL。 git remote add <name> <url>:将一个新的远程仓库添加到当前仓库中。<name>是远程仓库的简写名称,<url>是远程仓库的URL。 git remote rename <old-name> <new-name>:将已经存在的远程仓库的简写名称重命名为新的名称。 git remote remove <name>:从当前仓库中移除指定的远程仓库。 git remote set-url <name> <new-url>:修改指定远程仓库的URL。 git remote show <name>:显示指定远程仓库的详细信息,包括URL和跟踪分支。
|
设置私人令牌
1
| git remote set-url origin https://<your_token>@github.com/<USERNAME>/<REPO>.git
|
暂存区
查看代码行数
1
| git ls-files | xargs wc -l
|
1 2
| Username for 'https://gitee.com': momaoto Password for 'https://momaoto@gitee.com': 私人令牌
|
git原理:
conda
创建新环境
1
| conda create --name mesh2gs python=3.10
|
激活环境
退出当前环境
查看已有环境
删除不需要的环境
1
| conda env remove --name myenv
|
清理缓存
1 2
| pip cache purge conda clean --all
|