V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
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 · 2015-09-18 11:27:07 +08:00 · 1868 次点击
    这是一个创建于 3140 天前的主题,其中的信息可能已经有所发展或是发生改变。

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

    各位提供下思路?

    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])

    目前尚无回复
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5410 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 47ms · UTC 06:55 · PVG 14:55 · LAX 23:55 · JFK 02:55
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.