lianxi.py 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. import datetime #引入datetime模块
  2. # 获取时间
  3. str = datetime.datetime.now() #获取当前时间并转化成字符串
  4. print(str)
  5. print(datetime.datetime.now())
  6. a='asdasda'
  7. result = 'a' in a
  8. print(result)
  9. for i in range(1):
  10. print(i)
  11. # # 切割
  12. # # dep = request.GET["dep"].split('--')[0]
  13. # import math
  14. # a = " a'a/a,s-d,e#q%i^d&d%"
  15. # print(a.replace(" ", "").replace("/", "").replace(",", "").replace("-", "").replace("#", "").replace("%", "").replace("'", "").replace("^", "").replace("&", ""))
  16. #
  17. # #\r\n
  18. # #' '
  19. # #'
  20. # #--
  21. #
  22. #
  23. # if "asd' ".find("'") >= 0:
  24. # print('有空格')
  25. # # print('dada\n,dadad')
  26. # print('dadaoror \r\n,dadad')
  27. #
  28. # a={'the': 958035, 'of': 536684, 'and': 375233, 'one': 371796, 'in': 335503, 'a': 292250, 'to': 285093, 'zero': 235406, 'nine': 224705}
  29. # b = {}
  30. # for i,(k,v) in enumerate(a.items()):
  31. # print({k:v},end="")
  32. # b[k]=v
  33. # if i==4:
  34. # break
  35. # print(b)
  36. # import base64
  37. # # 使用的时候数据必须进行Bytes类型转换
  38. # # 方法encode()和decode()方法
  39. # # a = base64.b64encode(b'hello world')
  40. #
  41. #
  42. # # %s 字符串
  43. # # %d 整形
  44. # # %c 单字符
  45. # # %f 浮点数。控制为数 %.2f 保留两位小数
  46. # # %x 十六进制
  47. #
  48. # #打印结果:
  49. #
  50. # #
  51. # # print(str) #输出字符串信息
  52. #
  53. # #
  54. # #
  55. # # a= '20200219099'
  56. # #
  57. # # def monthly_odd(odd):
  58. # # """
  59. # # :param odd: 传入单号
  60. # # odd_old_right:旧单号右边三位数
  61. # # odd_old_left:旧单号左边8位数
  62. # # odd_new_right:新单号右边三位数
  63. # # odd_new:新单号
  64. # # :return:
  65. # # """
  66. # # odd_old = odd
  67. # # odd_old_right = int(odd_old[8::])+1 #右边三位
  68. # # odd_old_left = odd_old[0:8] #左边八位
  69. # # if len(str(odd_old_right))== 1:
  70. # # odd_new_right = '0'+'0'+str(odd_old_right) #新的右边三位
  71. # # odd_new = odd_old_left+odd_new_right
  72. # # return odd_new
  73. # # if len(str(odd_old_right))== 2:
  74. # # odd_new_right = '0'+str(odd_old_right)
  75. # # odd_new = odd_old_left+odd_new_right
  76. # # return odd_new
  77. # # if len(str(odd_old_right))== 3:
  78. # # odd_new_right = str(odd_old_right)
  79. # # odd_new = odd_old_left+odd_new_right
  80. # # return odd_new
  81. # # b = monthly_odd(a)
  82. # # print(b)
  83. #
  84. # def my_sum(n):
  85. # if n ==1:
  86. # return 1
  87. # return n+my_sum(n-1)
  88. # print(my_sum(3))
  89. # 1 2 3
  90. # import datetime
  91. # a = '2018-10-03 00:55:00'
  92. # b = datetime.datetime.strptime(a, '%Y-%m-%d %H:%M:%S').strftime('%Y-%m-%d %H:%M:%S')
  93. # print(b)
  94. # a = [{'mo':'mo1','qty':'1'},{'mo':'mo2','qty':'2'},{'mo':'mo3','qty':'3'},{'mo':'mo4','qty':'4'},{'mo':'mo5','qty':'5'}]
  95. # b={}
  96. # for i in a:
  97. # b['mo'+str(i['mo'])] = i['mo']
  98. # b['qty' + str(i['qty'])] = i['qty']
  99. # print(i)
  100. # print(b)
  101. # a = [{"a1":'1',"a2":'2'},{"a1":'1',"a2":'2'},{"a1":'1',"a2":'2'}]
  102. # print(a[0])
  103. # a1 = [{"a3":'3',"a4":'4'},{"a3":'3',"a4":'4'}]
  104. # aa = [{"a5":'5',"a6":'6'}]
  105. # a2 = {}
  106. # alist=[]
  107. # itm = 0
  108. # for i in range(len(a)):
  109. # a2.update(a[i])
  110. # a2.update(a1[i])
  111. # a.append(a2)
  112. # print(alist)
  113. # a = 1.2
  114. # print(round(a,0))