0%

修改工作路径方便测试开发

1
2
3
4
import os
# 修改工作路径方便测试开发
path = r"C:\Users\Administrator\Documents\GitHub\BF-grading-range\\"
os.chdir(path) # 也可 ../ 如此切换路径

此外

1
os.getcwd() # 查看工作路径

例子二

1
2
3
4
5
6
7
8
9
10
def chdir():
# 切换工作路径
import os
path = "../"
os.chdir(path)
a = os.getcwd()
print(a)

if __name__ == '__main__':
chdir()

参考

https://www.runoob.com/python/os-chdir.html

使用python的matplotlib库画图时,xlabel title 会出现中文无法显示的问题。可以参考一下代码解决问题

1
2
3
4
5
from matplotlib import pyplot as plt

# 修补画图时 中文乱码的问题
plt.rcParams['font.sans-serif'] = ['SimHei']
plt.rcParams['axes.unicode_minus'] = False

发现GitHub上有个Action功能. 查阅后,感觉它能当成一个远端的服务器用.
于是搜寻教程,自动在库 .github/workflows/目录下创建了.yml文件.
配置一下这个文件基本就万事大吉了.

主要实现让自己仓库里的文件能在action理运行, 并且让github回传送txt文件

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
name: Run Python & up .txt file
on:
push:
branches:
- master
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.8
uses: actions/setup-python@v1
with:
python-version: 3.8
- name: Run python
run: |
git clone https://github.com/Ackermannn/TestAction.git
python hello.py
- name: Up something
run: |
mkdir -p path/to/artifact
echo hello > path/to/artifact/world.txt
- uses: actions/upload-artifact@v1
with:
name: my-artifact
path: path/to/artifact

参考链接:

阮一峰的网络日志:GitHub Actions 入门教程

action/setup-python的官方文档

actions/upload-artifact

参考教程

参考知乎这个链接

https://zhuanlan.zhihu.com/p/106166402

B站里up主Codesheep也有搭建视频

https://www.bilibili.com/video/av44544186/

大体步骤

  1. 安装 git
  2. 安装Node.js
  3. 在Node.js里安装Hexo
  4. 选取喜欢的主题套用修改

安装中碰到的问题&解决方案

hexo d后 ERROR Deployer not found: git

解决git下载很慢的问题

HEXO安装(Win7 64 bit ),遇到cmd报错:’hexo’ 不是内部或外部命令,也不是可运行的程序
(简单总结:需要配置hexo的环境变量)

Tips:

  1. 把出现的错误代码直接复制到百度就可找到解决方法

  2. 在下载国外的一些工具时,可以考虑下载镜像,速度飞起

简单使用

创建新文件:

hexo n "新的文章名"

生成页面:

hexo g 

在本地浏览器查看效果:

hexo s

部署到远端服务器:

hexo d

更多资料

另外发现更多的Hexo教程
Hexo使用攻略

Icarus中文用户指南