testttt.py 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. #!/usr/bin/env python3
  2. # -*- coding: utf-8 -*-
  3. """
  4. @Copyright (C) ansjer cop Video Technology Co.,Ltd.All rights reserved.
  5. @AUTHOR: ASJRD018
  6. @NAME: AnsjerFormal
  7. @software: PyCharm
  8. @DATE: 2019/4/2 15:17
  9. @Version: python3.6
  10. @MODIFY DECORD:ansjer dev
  11. @file: testttt.py
  12. @Contact: chanjunkai@163.com
  13. """
  14. # !/usr/bin/python3
  15. # !/usr/bin/python3
  16. #
  17. # import uuid
  18. #
  19. #
  20. #
  21. # udt = uuid.uuid1()
  22. # print(udt)
  23. # exit()
  24. import oss2
  25. # 阿里云主账号AccessKey拥有所有API的访问权限,风险很高。强烈建议您创建并使用RAM账号进行API访问或日常运维,请登录 https://ram.console.aliyun.com 创建RAM账号。
  26. auth = oss2.Auth('LTAIyMkGfEdogyL9', '71uIjpsqVOmF7DAITRyRuc259jHOjO')
  27. # Endpoint以杭州为例,其它Region请按实际情况填写。
  28. bucket = oss2.Bucket(auth, 'oss-cn-shenzhen.aliyuncs.com', 'apg')
  29. # 设置此签名URL在60秒内有效。
  30. # url = bucket.sign_url('PUT', 'wupengyangceshi.png', 60)
  31. url = bucket.sign_url('GET', 'ADD2JGTZG22XBL2S111A/9/1546545891.jpeg', 60)
  32. print(url)
  33. exit()
  34. import requests
  35. didir = 'D:/13.56.215.252/git/AnsjerFormal/templates/adf.jpg'
  36. url = 'http://apg.oss-cn-shenzhen.aliyuncs.com/ADD2JGTZG22XBL2S111A%2F3%2F1546545891.jpeg?Expires=1554801938&Signature=UlZ5pCeBwYlVm07gdL2gp2UOFuU%3D&OSSAccessKeyId=LTAIyMkGfEdogyL9'
  37. r = requests.put(url,data=open(didir,'rb'))
  38. print(r.status_code)
  39. exit()
  40. import smtplib
  41. from email.mime.text import MIMEText
  42. from email.utils import formataddr
  43. # my_sender = '1758730877@qq.com' # 发件人邮箱账号
  44. # my_pass = 'jeridalqsufbdbdc' # 发件人邮箱密码
  45. my_sender = 'sara@zositech.com' # 发件人邮箱账号
  46. my_pass = 'FMEfRvfUDWNAj145' # 发件人邮箱密码
  47. my_user = '1758730877@qq.com' # 收件人邮箱账号,我这边发送给自己
  48. ret = True
  49. try:
  50. msg = MIMEText('填写邮件内容', 'plain', 'utf-8')
  51. msg['From'] = formataddr(["FromRunoob", my_sender]) # 括号里的对应发件人邮箱昵称、发件人邮箱账号
  52. msg['To'] = formataddr(["FK", my_user]) # 括号里的对应收件人邮箱昵称、收件人邮箱账号
  53. msg['Subject'] = "菜鸟教程发送邮件测试" # 邮件的主题,也可以说是标题
  54. server = smtplib.SMTP_SSL("hwsmtp.qiye.163.com", 994) # 发件人邮箱中的SMTP服务器,端口是25
  55. # server = smtplib.SMTP_SSL("smtp.qq.com", 465) # 发件人邮箱中的SMTP服务器,端口是25
  56. server.login(my_sender, my_pass) # 括号中对应的是发件人邮箱账号、邮箱密码
  57. server.sendmail(my_sender, [my_user, ], msg.as_string()) # 括号中对应的是发件人邮箱账号、收件人邮箱账号、发送邮件
  58. server.quit() # 关闭连接
  59. except Exception as e: # 如果 try 中的语句没有执行,则会执行下面的 ret=False
  60. print(repr(e))
  61. ret = False
  62. else:
  63. print('success')
  64. exit()
  65. import smtplib
  66. from email.mime.text import MIMEText
  67. from email.utils import formataddr
  68. my_sender = 'zositech@gmail.com' # 发件人邮箱账号
  69. my_pass = 'ZHzxb0805' # 发件人邮箱密码
  70. my_user = 'chanjunkai@163.com' # 收件人邮箱账号,我这边发送给自己
  71. ret = True
  72. try:
  73. msg = MIMEText('填写邮件内容', 'plain', 'utf-8')
  74. msg['From'] = formataddr(["FromRunoob", my_sender]) # 括号里的对应发件人邮箱昵称、发件人邮箱账号
  75. msg['To'] = formataddr(["FK", my_user]) # 括号里的对应收件人邮箱昵称、收件人邮箱账号
  76. msg['Subject'] = "菜鸟教程发送邮件测试" # 邮件的主题,也可以说是标题
  77. server = smtplib.SMTP_SSL("smtp.gmail.com", 465) # 发件人邮箱中的SMTP服务器,端口是25
  78. server.login(my_sender, my_pass) # 括号中对应的是发件人邮箱账号、邮箱密码
  79. server.sendmail(my_sender, [my_user, ], msg.as_string()) # 括号中对应的是发件人邮箱账号、收件人邮箱账号、发送邮件
  80. server.quit() # 关闭连接
  81. except Exception as e: # 如果 try 中的语句没有执行,则会执行下面的 ret=False
  82. print(repr(e))
  83. ret = False
  84. else:
  85. print('success')
  86. exit()
  87. # -*- coding: utf-8 -*-
  88. # import requests
  89. # url = requests.put('http://apg.oss-cn-shenzhen.aliyuncs.com/xaa?Signature=9nVkM5bE6%2B601E8kVPTlt%2B7zg%2FI%3D&OSSAccessKeyId=LTAIyMkGfEdogyL9&Expires=1554278510',data='asf')
  90. # print(url.status_code)
  91. # exit()
  92. import oss2
  93. # 阿里云主账号AccessKey拥有所有API的访问权限,风险很高。强烈建议您创建并使用RAM账号进行API访问或日常运维,请登录 https://ram.console.aliyun.com 创建RAM账号。
  94. auth = oss2.Auth('LTAIyMkGfEdogyL9', '71uIjpsqVOmF7DAITRyRuc259jHOjO')
  95. # Endpoint以杭州为例,其它Region请按实际情况填写。
  96. bucket = oss2.Bucket(auth, 'oss-cn-shenzhen.aliyuncs.com', 'cnvod1')
  97. # 设置此签名URL在60秒内有效。
  98. # url = bucket.sign_url('PUT', 'wupengyangceshi.png', 60)
  99. url = bucket.sign_url('PUT', 'wupengyangceshi.png', 60)
  100. print(url)
  101. # import requests
  102. # r = requests.put(url,data='xadf')
  103. # print(r.content)