-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathlib.py
More file actions
39 lines (31 loc) · 926 Bytes
/
lib.py
File metadata and controls
39 lines (31 loc) · 926 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import json
from jsonpath import jsonpath
from collections import Counter
import random
import string
import os
def analysis_test_results(file_path): # 统计 aug 的次数,返回一个字典
aug = []
file = open(file_path, encoding='utf-8')
for line in file.readlines():
d = json.loads(line)
if d['eval'] == 0:
aug.append(d['aug'])
print(dict(Counter(aug)))
def generate_random_str(randomlength):
'''
string.digits = 0123456789
string.ascii_letters = 26个小写,26个大写
'''
str_list = random.sample(string.digits + string.ascii_letters, randomlength)
random_str = ''.join(str_list)
return random_str
def generate_random_num(randomlength):
'''
string.digits = 0123456789
'''
str_list = random.sample(string.digits, randomlength)
random_str = ''.join(str_list)
return random_str
if __name__ == '__main__':
pass