qqwry.dat icon indicating copy to clipboard operation
qqwry.dat copied to clipboard

更新一个补丁

Open jingyuexing opened this issue 3 years ago • 0 comments

---
 update_chunzhen.py | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/update_chunzhen.py b/update_chunzhen.py
index 54e3939..064843e 100644
--- a/update_chunzhen.py
+++ b/update_chunzhen.py
@@ -103,14 +103,18 @@ def updateQQwry(filename):
         return -6
 
 if __name__ == '__main__':
-    import sys
-    if len(sys.argv) > 1:
-        ret = updateQQwry(sys.argv[1])
+    import argparse
+    argumentParser = argparse.ArgumentParser("download cz IP data")
+
+    argumentParser.add_argument("--file",help="download file of name",type=str)
+
+    args = argumentParser.parse_args()
+    print('args',args)
+    if(args.file != None):
+        ret = updateQQwry(f'{args.file}.dat')
         if ret > 0:
             print('成功更新到%s,%s字节' % 
-                  (sys.argv[1], format(ret, ','))
+                  (args.file, format(ret, ','))
                   )
         else:
-            print('更新失败,错误代码:%d' % ret)
-    else:
-        print('用法:以想要保存的文件名作参数。')
+            print('更新失败,错误代码:%d' % ret)
\ No newline at end of file
-- 

jingyuexing avatar May 20 '22 08:05 jingyuexing