假设文件目录关系如下

1
2
3
4
root
├─test
│ └─test_code.py
└─root_code.py

若要从test_code.py引入root_code.py模块,则test_code.py应当实现:

test/test_code.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import os
import sys

# print(sys.path)
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..',)))
# print(sys.path)

import root_code
# or
from root_code import *

...
阅读全文 »

方法一:使用图形界面

  1. 打开设置窗口
    • GNOME安装gnome-startup-applications(20.04后);在控制中心(Control Center)中寻找Startup Applications程序;或是在控制中心寻找Startup Applications Preferences选项[1]
    • MATE在控制中心(Control Center)中寻找Startup Applications选项[2]
  2. 增加启动项
    • Startup Applications Preferences窗口中新增项目,填写名称和命令。
  3. 重启检查效果
阅读全文 »

在写代码中有时需要适配不同的编译器和平台,一般通过判断编译器预定义的宏来确定所需信息。

这些信息可在以下网站找到:

  1. Pre-defined Compiler Macros wiki - GitHub
    Pre-defined Compiler Macros - SourceForge
    (二者内容完全相同)
  2. 2 Language Standards Supported by GCC (Using the GNU Compiler Collection (GCC))
  3. Predefined Macros (The C Preprocessor)
  4. Extensions to the C Language Family
    1. 扩展数据类型
      1. 128-bit Integers
      2. Double-Word Integers (Long Long);
      3. Half-Precision Floating Point
      4. Decimal Floating Types
    2. 属性
      1. Declaring Attributes of Functions
      2. Specifying Attributes of Variables
      3. Specifying Attributes of Types
      4. ...
阅读全文 »

如果一个项目需要同时在Linux下和Windows下编辑(例如WSL或者SCP拷贝),换行符的差别会带来各种兼容性问题,例如脚本无法运行、Git比较所有文件皆不相同等。因此需要统一格式。

阅读全文 »

故障

将未启动JTAG或SWD的程序烧入芯片,导致调试器无法调试和烧录新程序。

解决方法

BOOT0引脚拉高复位,然后就可以连接调试器了,烧录新程序后将BOOT0引脚拉低再复位,即可恢复正常。

阅读全文 »
0%