惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Simon Willison's Weblog
Simon Willison's Weblog
G
Google Developers Blog
Spread Privacy
Spread Privacy
I
InfoQ
V
V2EX
S
Schneier on Security
小众软件
小众软件
C
CERT Recently Published Vulnerability Notes
博客园 - 聂微东
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Stack Overflow Blog
Stack Overflow Blog
T
Threat Research - Cisco Blogs
L
Lohrmann on Cybersecurity
Recent Announcements
Recent Announcements
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Attack and Defense Labs
Attack and Defense Labs
云风的 BLOG
云风的 BLOG
The Hacker News
The Hacker News
S
SegmentFault 最新的问题
C
Cybersecurity and Infrastructure Security Agency CISA
NISL@THU
NISL@THU
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
GbyAI
GbyAI
Latest news
Latest news
S
Secure Thoughts
Project Zero
Project Zero
MongoDB | Blog
MongoDB | Blog
I
Intezer
Security Latest
Security Latest
Apple Machine Learning Research
Apple Machine Learning Research
Vercel News
Vercel News
N
Netflix TechBlog - Medium
V2EX - 技术
V2EX - 技术
量子位
T
Threatpost
T
The Blog of Author Tim Ferriss
Y
Y Combinator Blog
T
Tor Project blog
A
Arctic Wolf
Microsoft Security Blog
Microsoft Security Blog
T
The Exploit Database - CXSecurity.com
大猫的无限游戏
大猫的无限游戏
T
Tailwind CSS Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
C
Check Point Blog
博客园 - Franky
Google DeepMind News
Google DeepMind News
The Register - Security
The Register - Security
The GitHub Blog
The GitHub Blog
L
LINUX DO - 热门话题

博客园 - 网络隐士

[游戏] 连连看之eBay易趣搞笑版 [.NET之西天取经] (01) 即将踏上去硅谷的班机 张江大厦蒸包子,东湖物业真抠门 淘宝的人工封IP技术真好玩 感叹吴总落户易趣 美国签证二进宫 隐士搞定美国签证惊魂记 eBay之歌(Flash版) 阶乘运算之Python VS Java Python代码高亮显示工具 将GBK汉字转化为拼音的Python小程序 一个小巧的MySQL Shell 根据CDImage.cue产生自动改名命令的Python小程序 繁体中文转换为简体中文的PHP类 简体中文转换为繁体中文的PHP类 GBK汉字转化为拼音或笔画的PHP类 文本间加入任意字符的PHP函数 显示code39条形码的PHP类 JavaScript日历
一个小巧的Python Shell
网络隐士 · 2005-09-13 · via 博客园 - 网络隐士


import os
import sys
import string
import re

print "Written by caocao"
print "caocao@eastday.com"
print "http://nethermit.yeah.net"
print

if os.name=="nt":
 print "OS: Windows NT"
else:
 print "OS: Unknown"
print "Python Shell Version 1.0"
print
while True:
 try:
  command=string.strip(raw_input("PS "+os.getcwd()+">"), " ")
  commandLow=string.lower(command)
 except EOFError:
  break
 else:
  if commandLow=="exit" or commandLow=="quit":
   break
  elif commandLow=="":
   continue
  elif re.match("^[a-z]{1}:$", command, re.I)!=None:
   try:
    os.chdir(command)
   except OSError:
    print "No such file or directory"
  elif re.match("^cd (.+)$", command, re.I)!=None:
   matchObject=re.search("^cd (.+)$", command, re.I)
   if matchObject!=None:
    try:
     os.chdir(matchObject.group(1))
    except OSError:
     print "No such file or directory"
   else:
    print "Bad command"
  else:
   os.system(command)
  print
print "Byebye!"