美文网首页
利用Python生成UUID并在txt文件末尾写入

利用Python生成UUID并在txt文件末尾写入

作者: Winnnter | 来源:发表于2019-11-12 17:01 被阅读0次

需要安装uuid,configparser模块。
使用pip安装uuid模块,以及配置文件匹配模块:

pip install uuid
pip install configparser

脚本代码:

import os
import uuid
import configparser
#读取配置文件
cf = configparser.ConfigParser()
cf.read("F:\\video\\config.ini",encoding="UTF-8")
print(cf.get("HTTP","http_pre"))
#获取uuid
id = uuid.uuid1()
print(id)
print("'123'")
#写入的文件
file = r'F:\\test\\test.txt'
#在文件末尾进行写入
with open(file,'a+') as f:
    f.write(str(id)+'abc\n')

相关文章

网友评论

      本文标题:利用Python生成UUID并在txt文件末尾写入

      本文链接:https://www.haomeiwen.com/subject/fwyqictx.html