pydantic_test.py 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. """
  2. encoding: UTF-8
  3. @author:clx
  4. @file:pydantic_test.py
  5. @time:2023/5/29 22:55
  6. """
  7. import random
  8. import fastapi
  9. from starlette.responses import FileResponse
  10. # from fastapi.responses import FileResponse
  11. # from datetime import datetime
  12. # from typing import Optional, List
  13. #
  14. # from pydantic import BaseModel
  15. # from fastapi import FastAPI
  16. #
  17. # app = FastAPI()
  18. #
  19. # class User(BaseModel):
  20. # id:int
  21. # name:str = "Jone"
  22. # signup_ts = Optional[datetime]
  23. # friends:List[int]
  24. #
  25. # dic = {
  26. # "id":1,
  27. # "signup_ts":"2022-11-21",
  28. # "friends":[1,2,"3"]
  29. # }
  30. # user = User(**dic)
  31. # print(user.id)
  32. import os
  33. from pathlib import Path
  34. def fun():
  35. f = os.path.join(r"./", "name")
  36. print(f)
  37. print(Path(f).name)
  38. fr = FileResponse(
  39. path=f,
  40. filename=Path(f).name
  41. )
  42. # fun()
  43. # a = "dsadas.txt"
  44. # file_ext = os.path.splitext(a)
  45. # front,ext = file_ext
  46. # print(front,ext)
  47. # print("".join(random.sample("qwertyuiopasdfghjklzxcvbnm1234567890",5)))
  48. import time
  49. import re
  50. a = str(time.time())
  51. b = re.sub(r"\.","",a)
  52. print(b)