Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

更新一个补丁 #13

Open
jingyuexing opened this issue May 20, 2022 · 0 comments
Open

更新一个补丁 #13

jingyuexing opened this issue May 20, 2022 · 0 comments

Comments

@jingyuexing
Copy link

---
 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
-- 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant