问题描述
我有一个带有两个选项的python网络表单-文件上传和 textarea .我需要从每个值中获取值并将它们传递给另一个命令行程序.我可以轻松地通过文件上传选项传递文件名,但是我不确定如何传递textarea的值.
I have a python web form with two options - File upload and textarea. I need to take the values from each and pass them to another command-line program. I can easily pass the file name with file upload options, but I am not sure how to pass the value of the textarea.
我认为我需要做的是:
- 生成唯一的文件名
- 在工作目录中使用该名称创建一个临时文件
- 将从textarea传递的值保存到临时文件中
- 从我的python模块内部执行命令行程序,然后将临时文件的名称传递给它
我不确定如何生成唯一的文件名.有人可以给我一些有关如何生成唯一文件名的提示吗?任何算法,建议和代码行都会受到赞赏.
I am not sure how to generate a unique file name. Can anybody give me some tips on how to generate a unique file name? Any algorithms, suggestions, and lines of code are appreciated.
感谢您的关注
推荐答案
我认为您的问题不是很清楚,但是如果您需要的只是一个唯一的文件名...
I didn't think your question was very clear, but if all you need is a unique file name...
import uuid
unique_filename = str(uuid.uuid4())
这篇关于Python:如何创建唯一的文件名?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!