推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
v2LeoEx
V2EX  ›  Python

Python 思路

  •  
  •   v2LeoEx · Jan 9, 2020 · 3099 views
    This topic created in 2380 days ago, the information mentioned may be changed or developed.
    外网有个 json 文件,保存 10 条记录,每 2 小时更新一次,其中有一些是需要关注的,记录到本地 sqlite 中,
    1. 设计一个操作表的类 ,用来往表里增删改查操作
    2. 设计一个表示记录的类 ,代表 json 文件中一条记录, 解析 json 文件生成多个实例,用 list 保存起来,后面写到表中
    3. 其他一些操作, 开始时的读取配置文件,中间的爬取 json 文件到本地解析等

    问题是 3 这步是定义一个类, 用类中的多个方法实现这些诸如读配置, 爬取文件的操作。 还是单纯写几个函数, 在 main()里顺序执行 ?
    或者这么一个小的功能,爬取 json 文件, 解析, 保存到 sqlite 中, 哪位大佬有更‘优雅’的思路,
    感谢,好人一生平安
    watsy0007
        1
    watsy0007  
       Jan 9, 2020
    1. 使用三方操作 sqlite 类库.
    2. 单次查询对比更新数据.
    3. 配置定时任务.

    原则: 越简单实现越好, 上线再说.
    wzwwzw
        2
    wzwwzw  
       Jan 9, 2020
    写几个函数,写一个 main 方法,定时运行就可以了。先跑起来。
    shyrock
        3
    shyrock  
       Jan 9, 2020
    你的需求如此明确而简单,最优雅的思路就是一个 main 里面实现所有逻辑。
    抽象是为适配需求变动和复杂性而生的。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   4501 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 41ms · UTC 00:13 · PVG 08:13 · LAX 17:13 · JFK 20:13
    ♥ Do have faith in what you're doing.