浏览代码

Update me.py

蘭雅sRGB 3 年之前
父节点
当前提交
068a376957
共有 1 个文件被更改,包括 11 次插入10 次删除
  1. 11 10
      python/me.py

+ 11 - 10
python/me.py

@@ -1,29 +1,30 @@
 #-*- coding: UTF-8 -*- 
 import sys, os, readline
-
-# define Color
-Green = '\033[32m'; Red = '\033[31m'
-GreenBG = '\033[42;37m'; RedBG = '\033[41;37m'
+# Windows Usage:  python -m pip install pyreadline
+# https://git.io/me.py              # define Color 
+Green = '\033[32m'; Red = '\033[31m'; GreenBG = '\033[42;37m'; RedBG = '\033[41;37m'
 Yellow = '\033[0;33m'; SkyBlue = '\033[0;36m'; Font = '\033[0m'
-
 sys.ps1 = Red + '>' + Yellow + '>' + SkyBlue + '> ' + Font
 sys.ps2 = SkyBlue + '... ' + Font
 
+if (os.sep != '/'):   # Is Not Linux
+    Green = Red = GreenBG = RedBG = Yellow = SkyBlue = Font = ''
+
 def cls():
-    # print('\x1bc')
-    os.system('clear')
+    if (os.sep == '/'): os.system('clear')
+    else: os.system('cls')
 
 def pwd():
     print( SkyBlue + os.getcwd(), end = ' ')
 
 def ls():
     cur_path = os.getcwd()
-    os.system('ls -l ' + cur_path)
+    if (os.sep == '/'): os.system('ls -l ' + cur_path)
+    else: os.system('dir ' + cur_path)
     pwd()
 
 def cd(path = '.'):
-    os.chdir(path)
-    pwd()
+    os.chdir(path); pwd()
 
 def cat(file = 'me.py'):
     with open(file, 'r') as f: