Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

71 linhas
2.3KB

  1. # """
  2. # 模式 描述
  3. # r 以只读的形式打开文件,文件的指针在开头
  4. # r+ 读写,文件指针在开头
  5. # rb 以二进制的形式,只读文件指针在开头
  6. # w 只写,文件不存在,则创建新的,存在则覆盖,指针在开头
  7. # w+ 读写,文件不存在,则创建新的,存在则覆盖,指针在开头
  8. # wb 只写,以二进制的形式
  9. # a 追加模式,文件指针在结尾
  10. # a+ 读写,不存在则创建,存在直接追加
  11. # ab 以二进制形式追加
  12. #
  13. # 1. close(): 关闭文件---非常重要
  14. # 2. read([count]): 读取文件中的内容 count:字节数量
  15. # 3. readlines(): 读取所有内容,打包成列表
  16. # 4. readline(): 读取一行数据,追加读取,读取过的不能再次读取
  17. # 5. seek(offset,[from]): 修改指针的位置:从from位置移动了offset个字节,
  18. # from:0则表示从起始位置,1则表示从当前位置开始,2则表示从末尾开始
  19. # offset:要移动的字节数
  20. # 6. write(): 向文件中写入内容
  21. # """
  22. import json
  23. import sys
  24. import time
  25. import traceback
  26. from collections import namedtuple
  27. from queue import Queue
  28. import yaml
  29. #
  30. # import yaml
  31. #
  32. #
  33. # # 写文件
  34. # # with open("hello.txt", 'w') as f:
  35. # # f.write("hello world")
  36. # import pandas as pd
  37. # # 读文件
  38. ss = time.time()
  39. # with open(r"D:\tuoheng\codenew\tuoheng_alg\config\dsp_dev_service.yml",'r', encoding='utf-8') as f:
  40. # data = yaml.safe_load(f)
  41. with open(r"D:\tuoheng\codenew\tuoheng_alg\test\读写\dsp_application.json", 'r', encoding='utf-8') as f:
  42. a = json.loads(f.read())
  43. print(a)
  44. print(time.time()-ss)
  45. # # try:
  46. # # aa = Queue(1)
  47. # # aa.put(1, timeout=2)
  48. # # aa.put(2, block=True, timeout=5)
  49. # # except Exception as e:
  50. # # traceback_str = traceback.format_exc()
  51. # # print("aaaaaaaaaaaaaa", traceback_str)
  52. # import time
  53. # class a():
  54. # def __init__(self, value):
  55. # self.value = value
  56. #
  57. # def test(self):
  58. # num = 0
  59. # aa = self.value
  60. # while True:
  61. # num += 1
  62. # bb = aa
  63. # if num > 10000000:
  64. # break
  65. # ss = time.time()
  66. # a("1111").test()
  67. # print(time.time()-ss)
  68. envs = ('dev', 'test', 'prod')
  69. print('dev1' in envs)