Giter VIP home page Giter VIP logo

supermemo-toolkit's Introduction

Hi there 👋

  • 👋 Hi, I’m 星蓝 in Chinese,This is just my virtual identity.
  • 👀 The things that interest me are:法律、数学、英语、心理学、经济学、逻辑学、色彩与多样性、Python与NodeJS、……。
  • 🌱 I'm currently studying:英语、法律、数学
  • 📫 How to reach me: [email protected]

supermemo-toolkit's People

Contributors

zacharia2 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

supermemo-toolkit's Issues

用自然语言表达python

  • 迭代:从初始状态开始,每次迭代都遍历这个环,并更新状态,多次迭代直到到达结束状态。这里可以看为 for (i=1 , i<100 , i++)
  • 递归:想象成一个树结构,从字面可以其理解为重复“递推”和“回归”的过程,当“递推”到达底部时就会开始“回归”,其过程相当于树的深度优先遍历
# 对于 循环变量iterating_var 在序列sequence中进行迭代。
# 对一个序列里面的每一个元素进行处理。
for iterating_var in sequence:
   statements(s)

tqdm进度条

for i in tqdm(range(100), desc='Processing'):
    time.sleep(0.05)

基于迭代对象运行: tqdm(iterator)

SecureFileWrite

使用文件备份和临时文件:在进行文件写入之前,首先创建一个临时文件进行操作,最后将临时文件重命名为目标文件。这样可以确保即使意外终止,原始文件不会被破坏,可以使用备份文件进行恢复。

示例代码:

import shutil

backup_file = 'file.txt.bak'
temp_file = 'file.txt.tmp'

try:
    # 创建并写入临时文件
    with open(temp_file, 'w') as file:
        file.write('Hello, world!')
        # 在此处进行其他文件操作
    
    # 备份原始文件
    shutil.copyfile('file.txt', backup_file)
    
    # 重命名临时文件为目标文件
    shutil.move(temp_file, 'file.txt')
except Exception as e:
    # 发生异常时回滚备份文件
    shutil.move(backup_file, 'file.txt')
    print(f"写入文件时发生错误:{str(e)}")
finally:
    # 删除临时文件和备份文件
    if os.path.exists(temp_file):
        os.remove(temp_file)
    if os.path.exists(backup_file):
        os.remove(backup_file)

通过以上这些方法,你可以在读写文件时更加保险,确保数据不会因为意外终止而丢失。

Toc去重

def split_section(html, doc_id):

def getContent(book, href):

可以不用了。

缩短读取文件时间

'''
时间:2021.8.11
作者:手可摘星辰不去高声语
名称:08-案例-视频文件视频的拷贝.py
'''
 
# 1.导入包和模块
import multiprocessing
import os
 
 
def copy_file(file_name, source_dir, dest_dir):
    print(file_name, "--拷贝的进程pid是:", os.getpid())
    # 1.拼接源文件路径和目标文件所在的路径
    source_path = source_dir + "/" + file_name
    dest_path = dest_dir + "/" + file_name
    # 2.打开源文件和目标文件
    with open(source_path, "rb") as source_file:
        with open(dest_path, "wb") as dest_file:
            # 3.循环读取源文件到目标路径
            while True:
                data = source_file.read(1024)
                if data:
                    dest_file.write(data)
                else:
                    break
 
 
 
if __name__ == '__main__':
    # 1.定义源文件夹和目标文件夹
    source_dir = "源文件夹"
    dest_dir = "目标文件夹"
 
    # 2.创建目标文件夹
    try:
        os.mkdir(dest_dir)
    except:
        print("目标文件夹已经存在!")
 
    # 3.读取源文件夹的文件列表
    file_list = os.listdir(source_dir)
 
    # 4.遍历文件列表实现拷贝
    for file_name in file_list:
        # copy_file(file_name, source_dir, dest_dir)
        # 5.使用多进程实现多任务拷贝
        sub_process = multiprocessing.Process(target=copy_file,
                                              args=(file_name, source_dir, dest_dir))
        sub_process.start()

区分未修改的文件。

对于一个不断增加的文件列表,这个文件列表中会有被修改的文件。如何区分出没有被修改的文件呢?

首先是增加和删除,其次是修改和没修改。

修没修过怎么判断,文件哈希值(md5 sha1嘛?

图链整理小工具

如果是网络图片就下载下来,然后放到统一位置。要注意图片格式。

如果是本地图片,就改为相对路径。本地图片一般是绝对路径。

所以就是输入任意路径(非相对路径),输出一个相对路径。

采取对集合文件的一个个处理。

导入的XML内容排序不理想

使用Calibre将PDF文档转换成Epub格式,再通过power shell 将其转换成XML,导入到 SuperMemo 后,文字的排列如下。不知道是什么原因造成的,求救!
Uploading Screenshot 2024-02-29 at 11.39.16 AM.png…

意境语义

标识句子中的单词,并把当前单词单独标出。

统计句子中有多少单词被使用。

对句子进行分组,可以按照词频或者重要程度啥的。

元素中的空格被解析为问号

<html>
<body>
    <h1>这是 一个标题</h1>
    <p>这是 一个段落</p>
    <div>这是一个<div>内嵌的</div>块级元素</div>
</body>
</html>

例子,如何阅读一本书。

总结功能函数

希望提供一个函数,替换print函数,但,打印是在最后输出的信息。

层级问题

有本书:聪明人的个人成长.epub,层次有点问题。

image

memo

isinstance(chapter, tuple):

是元组的时候就说明是有子集的数据。元组的第一个元素是本层的数据,第二个元素是下一层的数据,也是入口。

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.