- 阿里云域名解析

- github-settings-pages

- hugo的配置修改hugo.yaml
将baseURL:
https://lwmfjc.github.io/doc修改为https://blog.liuyi2026.asia


https://lwmfjc.github.io/doc 修改为 https://blog.liuyi2026.asia
if some_condition:
# method1
# method2
elif some_other_condition:
#method3
#method4
else:
#method5
#method6
#method7>>> a=3;b=4;
>>> a
3
>>> b
4
>>> if a<b:
... print('a<b')
... elif a==5:
... print('a=5')
... else:
... print('other')
... print('hello world')
...
a<b
hello world
>>> a=5;b=2;
>>> if a<b:
... print('a<b')
... elif a==5:
... print('a=5')
... else:
... print('other')
... print('hello world')
...
a=5
hello world#检查相等性
>>> 2==2
True
>>> 2==1
False
>>> 'hello'=='bye'
False
>>> 'hi'=='hi'
True
>>> 2=='2'
False
>>> 2.0==2 #数值
True
>>> 3!=3
False
>>> 4!=5
True
>>> 2>1
True
>>> 1>2
False
>>> 1<2
True
>>> 2<5
True
>>> 2>=2
True
>>> 4<=1
False>>> 1<2
True
>>> 2<3
True
>>> 1<2<3 #直接串联
True
>>> 1<2>3
False
#使用逻辑运算符连接
>>> 1<2 and 2<3
True
>>> 'h' == 'h' and 2==2
True
>>> ('h' == 'h') and (2==2)
True
>>> 1<2 && 2<3
File "<python-input-23>", line 1
1<2 && 2<3
^
SyntaxError: invalid syntax
#注意,这是按位与运算符,且优先级高于<,>
>>> 3 < 4 & 4 < 5 #相当于 3< (4&4) <5,3 < 4 < 5
True>>> 1==1 or 2==2
True
>>> 100==1 or 2==2
True>>> 1==1
True
>>> not(1==1)
False
>>> not 1==1
False
>>> not 400>5000
True
>>> 1!=1
False
>>> not 1==1 #相比1!=1,逻辑更清晰点
False我下载的是绿色版:https://github.com/hluk/copyq
文件-命令-添加
显示高级,添加命令为 我这里替换…为几个空格。是因为我替换了从Python repl中复制过来的内容
copyq:
var text = str(clipboard());
var cleanedText = text.replace(/^\.\.\./gm, " ");
copy(cleanedText);
paste();设置全局快捷键:我这里设置成ctrl+shift+v
确认即可

截图时copyq会自动隐藏,原因不明,所以用手机拍
在jupyter中输入并运行
%%writefile myfile.txt
Hello this is a text file
this is the second line
this is the third line得到文件

注意,最后一行(第三行)最后还有一个换行符\n
也就是说,在jupyter输入的文本,都会以一个换行符结束输入
另一种情况,在linux下使用ipython命令行输入
In [2]: %%writefile myfile_linux.txt
...: a
...: b
...:
...:
Overwriting myfile_linux.txt在系统中查看,发现jupyter是没有空行的,而myfile_linux.txt则多了一个空行
(myenv) ly@dba13:~$ cat myfile_linux.txt
a
b
(myenv) ly@dba13:~$ cat myfile.txt #这个是我保存的jupyter编辑的文件
Hello this is a text file
this is the second line
this is the third line
(myenv) ly@dba13:~$ 
列表支持索引和切片,还支持嵌套 混合
>>> [1,"2",3.5,['a','b']]
[1, '2', 3.5, ['a', 'b']]
>>> a=[1,"2",3.5,['a','b']]
>>> a[3]
['a', 'b']
>>> a[3][1]
'b'>>> my_list=[1,2,3]
>>> my_list=['STRING',100,23.2]
>>> len(my_list)
3
>>> my_list[1:]
[100, 23.2]
>>> my_list[:1]
['STRING']
>>> mylist=['one','two','three']
>>> another_list=['four','five']
>>> mylist+another_list
['one', 'two', 'three', 'four', 'five']
>>> mylist
['one', 'two', 'three']
>>> another_list
['four', 'five']
>>> new_list=mylist+another_list
>>> new_list
['one', 'two', 'three', 'four', 'five']>>> new_list[0]='One All Caps'
>>> new_list
['One All Caps', 'two', 'three', 'four', 'five']
>>> new_list.append('six') #向后添加元素
>>> new_list
['One All Caps', 'two', 'three', 'four', 'five', 'six']
>>> new_list[-1]='heihei' #修改最后一个元素
>>> new_list
['One All Caps', 'two', 'three', 'four', 'five', 'heihei']
>>> len(new_list)
6
>>> new_list[6]='heihei' #向后添加元素不能用下标方式
Traceback (most recent call last):
File "<python-input-23>", line 1, in <module>
new_list[6]='heihei'
~~~~~~~~^^^
IndexError: list assignment index out of range
>>> new_list.pop
<built-in method pop of list object at 0x7f7a558dfb80>
#移除元素
>>> new_list.pop() #弹出并返回最后一个元素
'heihei'
>>> new_list
['One All Caps', 'two', 'three', 'four', 'five']
>>> popped_item=new_list.pop()
>>> popped_item
'five'
>>> new_list
['One All Caps', 'two', 'three', 'four']
#弹出指定索引的元素
>>> new_list
['One All Caps', 'two', 'three', 'four']
>>> new_list.pop(0)
'One All Caps'
>>> new_list
['two', 'three', 'four']
#弹出列表最后一个元素
>>> new_list.pop(-1)
'four'
>>> new_list
['two', 'three']sort 不返回任何类型
#接下来使用ipython
In [2]: print('hello')
hello
In [3]: print("Hello")
Hello
In [4]: print("I don't know")
I don't know
In [5]: print(' hah "hai"')
hah "hai"
#返回字符串(不是打印字符串),所以这里还显示了''表示这是一个字符串
In [1]: 'hello'
Out[1]: 'hello'
In [2]: "world"
Out[2]: 'world'
In [3]: 'this is a "Test'
Out[3]: 'this is a "Test'
In [4]: 'this is a "Test"'
Out[4]: 'this is a "Test"'
python xx.py时,这个代码出现在文件中,是会被合并成"hello1hello2"的,而且没人引用它,最终也会被丢弃
| Name | Type | Description |
|---|---|---|
| Integers | int | Whole numbers, such as: 3 300 200 |
| Floating point | float | Numbers with a decimal point: 2.3 4.6 100.0 |
| Strings | str | Ordered sequence of characters: "hello" 'Sammy' "2000" "楽しい" |
| Lists | list | Ordered sequence of objects: [10,"hello",200.3] |
| Dictionaries | dict | Unordered Key:Value pairs: {"mykey" : "value" , "name" : "Frankie"} |
| Tuples | tup | Ordered immutable sequence of objects: (10,"hello",200.3) |
| Sets | set | Unordered collection of unique objects: {"a","b"} |
| Booleans | bool | Logical value indicating True or False |
| 数据类型 | 类型标识 (Type) | 基础/典型占用字节 (Bytes) | 内存占用与扩容机制说明 |
|---|---|---|---|
| 布尔型 | bool | 28 字节 | True 和 False 是全局单例对象(继承自 int),固定占用 28 字节。 True or False |
| 整型 | int | 28 字节 | 基础 28 字节(存储 32 位以内的整数)。任意精度:数值超过 32 位(
)后,每增加 30 位数据递增 4 字节。 3 300 200 |
| 浮点型 | float | 24 字节 | 固定 24 字节(包含 8 字节 IEEE 754 双精度浮点数及对象头)。超出范围返回 inf 或下溢为 0.0。 2.3 4.6 100.0 |
| 字符串 | str | 48 字节(空串) | 根据最复杂字符自动选择编码:• ASCII / 纯英文:48 + 字符数×1 字节• Unicode / 中文日文:74 + 字符数×2 字节 "hello" 'Sammy' "2000" "楽しい" |
| 元组 | tup (tuple) | 40 字节(空元组)(3 元素示例:64 字节) | 计算公式约为
字节(
为指针数)。只存储元素指针,元素本身内存另计。不可变。 (10,"hello",200.3) |
| 列表 | list | 56 字节(空列表)(3 元素示例:88 字节) | 计算公式约为
字节。为保证追加效率会预分配容量(Over-allocation),仅存储元素指针。 [10,"hello",200.3] |
| 集合 | set | 216 字节(空集合) | 基于哈希表实现,初始即预分配包含 8 个槽位的哈希表,基础开销较大。 {"a","b"} |
| 字典 | dict | 64 字节(空字典)(2 键值对示例:184 字节) | 基于紧凑哈希表实现,包含索引数组与键值对数组。仅计字典结构及指针占用,Key 和 Value 对象本身内存另计。 {"mykey" : "value" , "name" : "Frankie"} |
| 数据类型 | == 比较标准 | 顺序敏感? | 独立定义时 a is b |
|---|---|---|---|
整型 (int) | 比较数值大小是否完全相同 | 不适用 | 常为 True(小整数区间 -5 到 257 会全局缓存地址;大整数在同一作用域下也有编译优化缓存) |
浮点型 (float) | 比较数值大小(注意 IEEE 754 精度误差) | 不适用 | 可能为 True(相同常量在同一代码块中会被编译优化指向同地址;不同代码块中为 False) |
字符串 (str) | 按字符序列及其顺序依次比较 | 敏感 | 常为 True(满足驻留机制 Interning 的短字符串或编译期常量会共享内存地址) |
Python 语言规范本身并没有强制要求必须指向同一地址,这是解释器为了节省内存和提高效率所做的优化。
本节学习:

http://localhost:11434/
ollama run qwen3:4b-instruct #会下载qwen3:4b-instruct大模型并运行,然后就可以问问题了
#这是我之后下载的几个,目前qwen3:4b 和 qwen3:4b-instruct 最符合电脑性能
ollama list | sort
deepseek-r1:1.5b e0979632db5a 1.1 GB 7 hours ago
deepseek-r1:7b 755ced02ce7b 4.7 GB 6 hours ago
gemma3:4b a2af6cc3eb7f 3.3 GB 2 hours ago
llama3.2:3b a80c4f17acd5 2.0 GB 6 hours ago
NAME ID SIZE MODIFIED
qwen3:4b 359d7dd4bcda 2.5 GB 8 hours ago
qwen3:4b-instruct 0edcdef34593 2.5 GB 7 hours ago
qwen3:8b 500a1f067a9f 5.2 GB 5 hours agoollama run qwen3:4b-instruct --hidethinking #使用hidethingking隐藏思考过程
#或者在运行中,使用/set nothink 隐藏思考过程,不过不是每个大模型都有效sudo apt install python3-requestsnano test_llm.pyimport requests
url = "http://192.168.6.201:11434/api/chat"
data = {
"model": "qwen3:4b-instruct",
"messages": [
{
"role": "user",
"content": "你好,随机给我一个五位数"
}
],
"stream": False
}
print("发送请求")
r = requests.post(
url,
json=data,
timeout=60
)
print("状态码:", r.status_code)
print(r.text)╭─ ~ ly@ubt24 18:10:49
╰─❯ python3 test_llm.py
发送请求
状态码: 200
{"model":"qwen3:4b-instruct","created_at":"2026-08-26T10:11:13.7346513Z","message":{"role":"assistant","content":"你好!这是一个随机生成的五位数:**73924** 😊\n\n如果需要更多,比如带条件的(比如是偶数、能被3整除等),也可以告诉我哦!"},"done":true,"done_reason":"stop","total_duration":7589013100,"load_duration":7398700,"prompt_eval_count":16,"prompt_eval_duration":143164000,"eval_count":46,"eval_duration":7413854000}这里用的其他模型,简单点 用了流式一个字一个字输出,也保留了完整聊天结果