Commit 7da09866 authored by BO ZHANG's avatar BO ZHANG 🏀
Browse files

add randfile

parent b0d4f4f4
from ._module_docstr import ModuleHeader
from ._io import remove_dir, remove_files
from .tempfile import randfile
import secrets
import string
def randfile(digits=20, ext=".fits"):
"""
Parameters
----------
digits
ext
Returns
-------
Examples
--------
>>> fname = randfile(20)
>>> print(fname)
"""
# 生成包含大小写字母和数字的字符集
characters = string.ascii_letters + string.digits
# 使用secrets模块生成指定长度的随机字符串
random_string = ''.join(secrets.choice(characters) for _ in range(digits)) + ext
return random_string
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment