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

python 数组处理问题

  •  
  •   2015yangdehua · Sep 18, 2015 · 2693 views
    This topic created in 4035 days ago, the information mentioned may be changed or developed.

    我这里有很多台机器,希望每次可以属于只需要输入序号就可以登录,但同时我的数组标注是字符串,同时又不希望每次输入很多个字母

    各位提供下思路?

    import os
    from array import *

    dblist={}
    dblist["adb"] =" ssh root@1"
    dblist["bdb"] ="ssh root@2"
    dblist["cdb"] =" ssh root@3"
    dblist["ddb"] = "ssh root@4"
    dblist["edb"] ="ssh root@5"
    count=0

    print dblist

    print "ID,name,IP"
    for key in dblist:
    print count,key,dblist[key]
    count=count+1
    content = raw_input ("Choose which id you would like to go:")
    print content
    print dblist[content]
    os.system (dblist[content])

    No Comments Yet
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   2391 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 22ms · UTC 06:46 · PVG 14:46 · LAX 23:46 · JFK 02:46
    ♥ Do have faith in what you're doing.