diff options
| author | dongxiaoyan <[email protected]> | 2020-04-01 12:42:05 +0800 |
|---|---|---|
| committer | dongxiaoyan <[email protected]> | 2020-04-01 12:42:05 +0800 |
| commit | acc676857bd85512f344a8d06aa1ae8846e7c0db (patch) | |
| tree | f2a7e19139d7f763e699ae10a997184c168fed76 /04-CustomLibrary/FileLibrary | |
Diffstat (limited to '04-CustomLibrary/FileLibrary')
| -rw-r--r-- | 04-CustomLibrary/FileLibrary/__init__.py | 7 | ||||
| -rw-r--r-- | 04-CustomLibrary/FileLibrary/filetool.py | 27 |
2 files changed, 34 insertions, 0 deletions
diff --git a/04-CustomLibrary/FileLibrary/__init__.py b/04-CustomLibrary/FileLibrary/__init__.py new file mode 100644 index 0000000..29db0ed --- /dev/null +++ b/04-CustomLibrary/FileLibrary/__init__.py @@ -0,0 +1,7 @@ +#coding=utf-8 +from filetool import filetool + +version = '1.0' + +class FileLibrary(filetool): + ROBOT_LIBRARY_SCOPE = 'GLOBAL'
\ No newline at end of file diff --git a/04-CustomLibrary/FileLibrary/filetool.py b/04-CustomLibrary/FileLibrary/filetool.py new file mode 100644 index 0000000..56eadcf --- /dev/null +++ b/04-CustomLibrary/FileLibrary/filetool.py @@ -0,0 +1,27 @@ +#coding=utf-8 +import sys +reload(sys) +sys.setdefaultencoding("utf-8") + +""" 变量文件操作 """ + +class filetool(): + def __init__(self): + pass + + def alter_dict(self, path, k, v): + data = '' + flag = True + key = '${%s}' % (k) + add = key + '\t%s' % (v) + '\n' + with open(path, 'r+') as f: + for line in f.readlines(): + if(line.find(key + '\t') == 0): + line = add + flag = False + data += line + if(flag): + data += add + print data + with open(path, 'w+') as f: + f.writelines(data)
\ No newline at end of file |
