更新时间 2022-12-28

遇到了一个比较有意思的问题,表示复数一般有两种方法,其中一种如下表示: c = a + bi c = a + bi 其中 cc 表示复数,而它有两部分组成其中 aa 表示实数部分,bb 表示虚数部分,i = \sqrt{-1}i = \sqrt{-1} 表示虚数单位。数学上一般用 ii 来表示虚数单位,是 imaginary 的首字母。 Python 但是,Python 中用 jj 来表示虚数单位,这是一个不一致,并且不是显然的,所以一定有某些历史性的原因导致了这个选择。 经过一番搜索 Stac

更新时间 2021-12-12

print("Hello Jupyter") Hello Jupyter import numpy as np import matplotlib.pyplot as plt data = {'a': np.arange(50), 'c': np.random.randint(0, 50, 50), 'd': np.random.randn(50)} data['b'] = data['a'] + 10 * np.random.randn(50) data['d'] =

更新时间 2021-09-12

处理的方式及其简单,就是图像中有模式固定但是位置不固定的水印,而且背景颜色单一,这样就可以使用如下代码去之; 代码如下,其中: template 是图像中水印位置的截图 rectangle 中的参数 (255, 255, 255) 是背景颜色,此处是白色 # coding=utf-8 import os import glob import cv2 import numpy as np dirname = os.path.dirname(__file__) os.chdir(dirname) de

更新时间 2021-09-11

In [1]: import networkx as nx import matplotlib.pyplot as plt import numpy as np In [2]: SIZE = 10 T = nx.DiGraph() A = np.zeros((SIZE, SIZE)) for i in range(SIZE): for j in range(i): if i == j: pass else:

更新时间 2021-03-11

C #include <stdio.h> int main() { printf("hello world\n"); return 0; } C++ #include <iostream> int main() { std::cout << "hello world" << std::endl; return 0; } Python print('hello world') Java public class Hello{ public static voi

更新时间 2020-11-30

矩阵求逆 测试矩阵如下: A = \left[ \begin{array}{ccc} 1 & 1 & 1 \\ 1 & 2 & 3 \\ 1 & 4 & 9 \\ \end{array} \right] A = \left[ \begin{array}{ccc} 1 & 1 & 1 \\ 1 & 2 & 3 \\ 1 & 4 & 9 \\ \end{array} \right] import numpy as np # 初始化一个非奇异矩阵(数组) a = np.array([[1, 1, 1], [

更新时间 2020-11-16

在 CentOS 上安装 Python 3.6 需要执行一下命令 # yum install epel-release # yum install python36 配置pypi用户名密码 修改配置文件 ~/.pypirc [distutils] index-servers = pypi [pypi] username:username of yours password:password of yours pypi 打包上传命令 python setup.py sdist bdist_whee

更新时间 2019-07-30

基本概念 关于音频文件,有几个基础的概念需要说明一下: 位数 音频量化位数,采样的精度。与位图的位数相对,一般的8位位图,总共有 0~255 个灰度值,RGB色彩格式表示了 RGB这三种颜色,各个颜色的颜色深度。而音频是录音设备在特定的时刻记录当时空气的张力值,可以这么理解吧。16位深度的录音设备可以保存的范围是 0~65535,所以声音震动产生的张力总会被量化到这个范围中,准确性会因为量化而有所损失。 采样率 每秒钟的采样数量,通常为 41000 Hz,或者 48000 Hz,人耳能听到的频率为 20 ~

更新时间 2019-07-30

sqlite 数据库配置 DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), } } MySQL 数据库配置 DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', # 数据库引擎

更新时间 2019-07-30

Django 时区操作 一般情况下,习惯了Linux的用户在 Django 开发中设置的时区是 Asia/Shanghai 也就是上海。 Django 开发过程中,使用时区的的情况下,设置 settings 中 USE_TZ = True,这样就会有两种时间,一种没有时区信息的,用 datetime 生成,一种带时区信息的,用 timezone.now 生成。 有时候需要在已经生成的时间进行转换,一种情况是已经有了时区,需要去掉,一种是没有时区,需要加上时区。更多的是没有时区,然后加上时区。 一种实