记python2topython3失败记录及网络扫描脚本

打算封装一下网络扫描到到docker镜像中, 转换版本记录如下  print都没有转换成功  输出内容如下

#powershell执行命令:
python  2to3.py  D:\code\wemonitor\scriptTest\bin\netscan.py


#输出结果:

RefactoringTool: Skipping optional fixer: buffer
RefactoringTool: Skipping optional fixer: idioms
RefactoringTool: Skipping optional fixer: set_literal
RefactoringTool: Skipping optional fixer: ws_comma
RefactoringTool: Refactored D:\code\wemonitor\scriptTest\bin\netscan.py
--- D:\code\wemonitor\scriptTest\bin\netscan.py (original)
+++ D:\code\wemonitor\scriptTest\bin\netscan.py (refactored)
@@ -1,7 +1,7 @@
 #!/usr/bin/env python2
 # -*- conding: UTF-8 -*-
 import os
-import commands
+import subprocess
 import subprocess
 import re

@@ -14,7 +14,7 @@
         \n\
         \n                Please: "
     while 1:
-        n_net = input(prompt)
+        n_net = eval(input(prompt))
         #    n_net_match = re.match('(10|172|192).\d{1,3}.\d{1,3}.0/\d{1,2}', n_net)
         n_net_match = re.match('\d{1,3}.\d{1,3}.\d{1,3}.0/\d{1,2}', n_net)
         if n_net == "":
@@ -136,32 +136,32 @@
                 continue
             else:
                 w_no_pair_list.append(www)
-        print
+        print()
         "\n============ Pair IP ============="
         for pip in pair_list:
-            print
+            print()
             pip
-        print
+        print()
         "                                        Summary: %s" % len(pair_list)
-        print
+        print()
         "\n=========== No Pair NIP ==========="
         for nnpip in n_no_pair_list:
-            print
+            print()
             nnpip
-        print
+        print()
         "                  Summary: %s" % len(n_no_pair_list)
-        print
+        print()
         "\n=========== No Pair WIP ==========="
         for wnpip in w_no_pair_list:
-            print
+            print()
             wnpip
-        print
+        print()
         "                  Summary: %s" % len(w_no_pair_list)
         # os.system("pause")
     else:
         for final_n in n_available_list:
-            print
+            print()
             final_n
-        print
+        print()
         "                  Summary: %s" % len(n_available_list)
         # os.system("pause")
RefactoringTool: Files that need to be modified:
RefactoringTool: D:\code\wemonitor\scriptTest\bin\netscan.py

脚本代码如下:

https://github.com/zenthought/wemonitor/blob/master/scriptTest/bin/netscan.py

猜你喜欢

转载自blog.csdn.net/wuxingpu5/article/details/100573025