推荐学习书目
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
juventusryp
V2EX  ›  Python

如何将一个 word 里的几百个单词随机分组

  •  
  •   juventusryp · Nov 2, 2016 · 2926 views
    This topic created in 3540 days ago, the information mentioned may be changed or developed.
    现有一个 word 文件,里面有 200 个单词(一个单词一行),如果想随机分 18 组,每组 50 个,再输出到 word 里,可以用 python 实现吗?

    具体该用什么实现?
    3 replies    2016-11-02 18:05:32 +08:00
    purebluesong
        1
    purebluesong  
       Nov 2, 2016
    shuffle
    linuxplus
        2
    linuxplus  
       Nov 2, 2016
    直接命令行操作如何?
    $ split -l 50 abc.txt

    或者先简单乱序,再 split ?
    while read i; do echo "$i $RANDOM"; done< abc.txt | sort -k2n | cut -d" " -f1
    jimzhong
        3
    jimzhong  
       Nov 2, 2016
    random.shuffle(words)
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2621 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 45ms · UTC 15:42 · PVG 23:42 · LAX 08:42 · JFK 11:42
    ♥ Do have faith in what you're doing.