summaryrefslogtreecommitdiff
path: root/customlib/common
diff options
context:
space:
mode:
Diffstat (limited to 'customlib/common')
-rw-r--r--customlib/common/__pycache__/common.cpython-36.pycbin0 -> 1298 bytes
-rw-r--r--customlib/common/__pycache__/common.cpython-37.pycbin0 -> 1297 bytes
-rw-r--r--customlib/common/__pycache__/type_judgment.cpython-36.pycbin0 -> 271 bytes
-rw-r--r--customlib/common/__pycache__/type_judgment.cpython-37.pycbin0 -> 261 bytes
-rw-r--r--customlib/common/__pycache__/util.cpython-36.pycbin0 -> 646 bytes
-rw-r--r--customlib/common/common.py51
-rw-r--r--customlib/common/type_judgment.py4
-rw-r--r--customlib/common/util.py17
8 files changed, 72 insertions, 0 deletions
diff --git a/customlib/common/__pycache__/common.cpython-36.pyc b/customlib/common/__pycache__/common.cpython-36.pyc
new file mode 100644
index 0000000..365d645
--- /dev/null
+++ b/customlib/common/__pycache__/common.cpython-36.pyc
Binary files differ
diff --git a/customlib/common/__pycache__/common.cpython-37.pyc b/customlib/common/__pycache__/common.cpython-37.pyc
new file mode 100644
index 0000000..a3dbf44
--- /dev/null
+++ b/customlib/common/__pycache__/common.cpython-37.pyc
Binary files differ
diff --git a/customlib/common/__pycache__/type_judgment.cpython-36.pyc b/customlib/common/__pycache__/type_judgment.cpython-36.pyc
new file mode 100644
index 0000000..8262ea4
--- /dev/null
+++ b/customlib/common/__pycache__/type_judgment.cpython-36.pyc
Binary files differ
diff --git a/customlib/common/__pycache__/type_judgment.cpython-37.pyc b/customlib/common/__pycache__/type_judgment.cpython-37.pyc
new file mode 100644
index 0000000..badeef8
--- /dev/null
+++ b/customlib/common/__pycache__/type_judgment.cpython-37.pyc
Binary files differ
diff --git a/customlib/common/__pycache__/util.cpython-36.pyc b/customlib/common/__pycache__/util.cpython-36.pyc
new file mode 100644
index 0000000..f849b62
--- /dev/null
+++ b/customlib/common/__pycache__/util.cpython-36.pyc
Binary files differ
diff --git a/customlib/common/common.py b/customlib/common/common.py
new file mode 100644
index 0000000..2d282ed
--- /dev/null
+++ b/customlib/common/common.py
@@ -0,0 +1,51 @@
+import json
+import random
+import hashlib
+import os
+
+#判断一个字符或字符串是否包含于另一个字符串:a是否再b中,是否则返回True,否则返回Falsle
+def aisincludeb(a,b):
+ result = a in b
+ print(result)
+ return result
+
+#删除字符串当前前几个,或后几个:sourcestr源串,a[2:-2] 表示去掉前面两个和后面两个,如果光去掉后面的a[:-2]
+def removeBeforOrAfter(sourcestr,a):
+ #a = "16541616584984"
+ #a = a[2:-2]
+ sourcestr = sourcestr[a]
+ return result
+
+#分离字符串
+def string2list(str,split):
+ return str.split(split)
+
+#用于生成一个指定范围内的整数
+def randomint(a,b):
+ return random.randint(a,b)
+
+#较小文件处理方法:
+def get_md5_01(file_path):
+ md5 = None
+ if os.path.isfile(file_path):
+ f = open(file_path,'rb')
+ md5_obj = hashlib.md5()
+ md5_obj.update(f.read())
+ hash_code = md5_obj.hexdigest()
+ f.close()
+ md5 = str(hash_code).lower()
+ return md5
+
+#较大文件处理方法:
+def get_md5_02(file_path):
+ f = open(file_path,'rb')
+ md5_obj = hashlib.md5()
+ while True:
+ d = f.read(8096)
+ if not d:
+ break
+ md5_obj.update(d)
+ hash_code = md5_obj.hexdigest()
+ f.close()
+ md5 = str(hash_code).lower()
+ return md5 \ No newline at end of file
diff --git a/customlib/common/type_judgment.py b/customlib/common/type_judgment.py
new file mode 100644
index 0000000..f3765ce
--- /dev/null
+++ b/customlib/common/type_judgment.py
@@ -0,0 +1,4 @@
+
+def dataType(data):
+ type1=type(data)
+ return type1
diff --git a/customlib/common/util.py b/customlib/common/util.py
new file mode 100644
index 0000000..98befec
--- /dev/null
+++ b/customlib/common/util.py
@@ -0,0 +1,17 @@
+import socket
+import fcntl
+import struct
+import string
+
+def get_ip_address(ifname):
+ s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
+ return socket.inet_ntoa(fcntl.ioctl(
+ s.fileno(),
+ 0x8915, # SIOCGIFADDR
+ struct.pack('256s', ifname[:15])
+ )[20:24])
+
+#get_ip_address('eth0') # '192.168.0.110'
+
+def source_str_is_cotain_destion_str(sourcestr,destionstr):
+ return string.find(sourcestr,destionstr)!=-1 \ No newline at end of file