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

想问下正文中的 Ruby 代码如果用 Python 该怎么实现

  •  
  •   xudongsong · Apr 1, 2015 · 2373 views
    This topic created in 4201 days ago, the information mentioned may be changed or developed.

    def run(desc, &block)
    puts "\n#{desc} start @ #{Time.now}"
    block.call
    if !$?.nil?
    warn "#{desc} fail" unless $?.success?
    puts "#{desc} #{$?.success? ? 'success' : 'fail'} @ #{Time.now}"
    exit $?.exitstatus unless $?.success?
    end
    end

    run "cd" do
    system 'mkdir test' unless File.exist?('test')
    system "cd test"
    end

    run "ls" do
    system "ls"
    end

    其实主要是不知道block该怎么改写

    1 replies  •  2015-04-07 00:19:26 +08:00
    ming2281
        1
    ming2281  
       Apr 7, 2015
    没有缩进,没有"食欲"啊
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   2341 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 01:38 · PVG 09:38 · LAX 18:38 · JFK 21:38
    ♥ Do have faith in what you're doing.