Browse Source

Merge branch 'release' of gitadmin/tuoheng_alg into master

tags/V2.7.6
chenyukun 1 year ago
parent
commit
befdbe9763
66 changed files with 1746 additions and 111 deletions
  1. +98
    -106
      .idea/workspace.xml
  2. +130
    -0
      demo1.py
  3. BIN
      test/__pycache__/__init__.cpython-38.pyc
  4. +55
    -0
      test/collections/ChainMap.py
  5. +111
    -0
      test/collections/Counter.py
  6. +35
    -0
      test/collections/OrderedDict.py
  7. +30
    -0
      test/collections/__init__.py
  8. +66
    -0
      test/collections/defaultdict.py
  9. +148
    -0
      test/collections/deque.py
  10. +83
    -0
      test/collections/namedtuple.py
  11. +0
    -0
      test/cpu/__init__.py
  12. +44
    -0
      test/cpu/test.py
  13. +0
    -0
      test/ip/__init__.py
  14. +34
    -0
      test/ip/test.py
  15. +0
    -0
      test/os/__init__.py
  16. +15
    -0
      test/os/test.py
  17. +0
    -0
      test/wifi/__init__.py
  18. +9
    -0
      test/wifi/test.py
  19. +5
    -0
      test/偏函数/__init__.py
  20. +50
    -0
      test/偏函数/cmp_to_key.py
  21. +31
    -0
      test/偏函数/demo.py
  22. +39
    -0
      test/偏函数/singledispatch.py
  23. +26
    -0
      test/偏函数/wraps.py
  24. +0
    -0
      test/内置函数/__init__.py
  25. +11
    -0
      test/内置函数/test.py
  26. +21
    -0
      test/序列化/test1.py
  27. +0
    -0
      test/异常/__init__.py
  28. +6
    -0
      test/异常/test.py
  29. +29
    -0
      test/正则/demo.py
  30. +62
    -0
      test/游戏/Food.py
  31. +93
    -0
      test/游戏/SnakeGame.py
  32. +0
    -0
      test/游戏/__init__.py
  33. BIN
      test/游戏/__pycache__/Food.cpython-38.pyc
  34. BIN
      test/游戏/__pycache__/__init__.cpython-38.pyc
  35. BIN
      test/游戏/food.png
  36. BIN
      test/游戏/snake.png
  37. +0
    -0
      test/算法/__init__.py
  38. +20
    -0
      test/算法/冒泡.py
  39. +21
    -0
      test/算法/插入.py
  40. +21
    -0
      test/算法/选择.py
  41. +29
    -0
      test/类型标注/test1.py
  42. +1
    -1
      test/设计模式/简单工厂模式/demo1.py
  43. +0
    -0
      test/语法/__init__.py
  44. +0
    -0
      test/语法/datetime/__init__.py
  45. +106
    -0
      test/语法/datetime/test.py
  46. +0
    -0
      test/语法/for/__init__.py
  47. +43
    -0
      test/语法/for/demo.py
  48. +0
    -0
      test/语法/list/__init__.py
  49. +34
    -0
      test/语法/list/demo.py
  50. +0
    -0
      test/语法/statistics_test/__init__.py
  51. +16
    -0
      test/语法/statistics_test/test.py
  52. +0
    -0
      test/语法/time/__init__.py
  53. +42
    -0
      test/语法/time/test.py
  54. +27
    -0
      test/语法/全局变量.py
  55. +51
    -0
      test/语法/全局变量1.py
  56. +39
    -0
      test/语法/回调.py
  57. +0
    -0
      test/语法/装饰器/__init__.py
  58. +0
    -0
      test/读写/__init__.py
  59. +20
    -0
      test/读写/csv_test.py
  60. +4
    -0
      test/读写/data.csv
  61. +29
    -0
      test/读写/demo.py
  62. +1
    -0
      test/读写/hello.txt
  63. +0
    -1
      util/AliyunSdk.py
  64. +11
    -3
      util/Cv2Utils.py
  65. BIN
      vodsdk/__pycache__/AliyunVodUploader.cpython-38.pyc
  66. BIN
      vodsdk/__pycache__/AliyunVodUtils.cpython-38.pyc

+ 98
- 106
.idea/workspace.xml View File

@@ -6,16 +6,6 @@
<component name="ChangeListManager">
<list default="true" id="4f7dccd9-8f92-4a6e-90cc-33890d102263" name="Changes" comment="Changes">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/concurrency/FileUploadThread.py" beforeDir="false" afterPath="$PROJECT_DIR$/concurrency/FileUploadThread.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/concurrency/IntelligentRecognitionProcess.py" beforeDir="false" afterPath="$PROJECT_DIR$/concurrency/IntelligentRecognitionProcess.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/concurrency/PullVideoStreamProcess.py" beforeDir="false" afterPath="$PROJECT_DIR$/concurrency/PullVideoStreamProcess.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/dsp_master.py" beforeDir="false" afterPath="$PROJECT_DIR$/dsp_master.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/enums/ExceptionEnum.py" beforeDir="false" afterPath="$PROJECT_DIR$/enums/ExceptionEnum.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/service/Dispatcher.py" beforeDir="false" afterPath="$PROJECT_DIR$/service/Dispatcher.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/test/ffmpeg11/aa.py" beforeDir="false" afterPath="$PROJECT_DIR$/test/ffmpeg11/aa.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/test/日志/test.py" beforeDir="false" afterPath="$PROJECT_DIR$/test/日志/test.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/test/线程/Test.py" beforeDir="false" afterPath="$PROJECT_DIR$/test/线程/Test.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/util/AliyunSdk.py" beforeDir="false" afterPath="$PROJECT_DIR$/util/AliyunSdk.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/util/Cv2Utils.py" beforeDir="false" afterPath="$PROJECT_DIR$/util/Cv2Utils.py" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
@@ -135,47 +125,47 @@
<option name="hideEmptyMiddlePackages" value="true" />
<option name="showLibraryContents" value="true" />
</component>
<component name="PropertiesComponent"><![CDATA[{
"keyToString": {
"RunOnceActivity.OpenProjectViewOnStart": "true",
"RunOnceActivity.ShowReadmeOnStart": "true",
"WebServerToolWindowFactoryState": "true",
"WebServerToolWindowPanel.toolwindow.highlight.mappings": "true",
"WebServerToolWindowPanel.toolwindow.highlight.symlinks": "true",
"WebServerToolWindowPanel.toolwindow.show.date": "false",
"WebServerToolWindowPanel.toolwindow.show.permissions": "false",
"WebServerToolWindowPanel.toolwindow.show.size": "false",
"last_opened_file_path": "D:/tuoheng/codenew/tuoheng_alg/test/元类",
"node.js.detected.package.eslint": "true",
"node.js.detected.package.tslint": "true",
"node.js.selected.package.eslint": "(autodetect)",
"node.js.selected.package.tslint": "(autodetect)",
"nodejs_package_manager_path": "npm",
"project.structure.last.edited": "SDK",
"project.structure.proportion": "0.15",
"project.structure.side.proportion": "0.2816092",
"settings.editor.selected.configurable": "preferences.pluginManager",
"vue.rearranger.settings.migration": "true"
<component name="PropertiesComponent">{
&quot;keyToString&quot;: {
&quot;RunOnceActivity.OpenProjectViewOnStart&quot;: &quot;true&quot;,
&quot;RunOnceActivity.ShowReadmeOnStart&quot;: &quot;true&quot;,
&quot;WebServerToolWindowFactoryState&quot;: &quot;true&quot;,
&quot;WebServerToolWindowPanel.toolwindow.highlight.mappings&quot;: &quot;true&quot;,
&quot;WebServerToolWindowPanel.toolwindow.highlight.symlinks&quot;: &quot;true&quot;,
&quot;WebServerToolWindowPanel.toolwindow.show.date&quot;: &quot;false&quot;,
&quot;WebServerToolWindowPanel.toolwindow.show.permissions&quot;: &quot;false&quot;,
&quot;WebServerToolWindowPanel.toolwindow.show.size&quot;: &quot;false&quot;,
&quot;last_opened_file_path&quot;: &quot;D:/tuoheng/codenew/tuoheng_dsp&quot;,
&quot;node.js.detected.package.eslint&quot;: &quot;true&quot;,
&quot;node.js.detected.package.tslint&quot;: &quot;true&quot;,
&quot;node.js.selected.package.eslint&quot;: &quot;(autodetect)&quot;,
&quot;node.js.selected.package.tslint&quot;: &quot;(autodetect)&quot;,
&quot;nodejs_package_manager_path&quot;: &quot;npm&quot;,
&quot;project.structure.last.edited&quot;: &quot;SDK&quot;,
&quot;project.structure.proportion&quot;: &quot;0.15&quot;,
&quot;project.structure.side.proportion&quot;: &quot;0.2816092&quot;,
&quot;settings.editor.selected.configurable&quot;: &quot;preferences.pluginManager&quot;,
&quot;vue.rearranger.settings.migration&quot;: &quot;true&quot;
}
}]]></component>
}</component>
<component name="RecentsManager">
<key name="CopyFile.RECENT_KEYS">
<recent name="D:\tuoheng\codenew\tuoheng_alg\test\元类" />
<recent name="D:\tuoheng\codenew\tuoheng_alg" />
<recent name="D:\tuoheng\codenew\tuoheng_alg\test\color" />
<recent name="D:\tuoheng\codenew\tuoheng_alg\test\cuda" />
<recent name="D:\tuoheng\codenew\tuoheng_alg\util" />
<recent name="D:\tuoheng\codenew\tuoheng_alg\test\算法" />
<recent name="D:\tuoheng\codenew\tuoheng_alg\test\语法" />
<recent name="D:\tuoheng\codenew\tuoheng_alg\test\正则" />
<recent name="D:\tuoheng\codenew\tuoheng_alg\test\类型标注" />
<recent name="D:\tuoheng\codenew\tuoheng_alg\test\游戏" />
</key>
<key name="MoveFile.RECENT_KEYS">
<recent name="D:\tuoheng\codenew\tuoheng_alg" />
<recent name="D:\tuoheng\codenew\tuoheng_alg\test\设计模式\单例" />
<recent name="D:\tuoheng\codenew\tuoheng_alg\font" />
<recent name="D:\work\alg_new\tuoheng_alg\test\image" />
<recent name="D:\work\alg\tuoheng_alg\test\水印" />
<recent name="D:\work\alg\tuoheng_alg\image" />
</key>
</component>
<component name="RunManager" selected="Python.demo1">
<configuration name="demo" type="PythonConfigurationType" factoryName="Python" temporary="true" nameIsGenerated="true">
<component name="RunManager" selected="Python.冒泡">
<configuration name="冒泡" type="PythonConfigurationType" factoryName="Python" temporary="true" nameIsGenerated="true">
<module name="tuoheng_alg" />
<option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" />
@@ -183,12 +173,12 @@
<env name="PYTHONUNBUFFERED" value="1" />
</envs>
<option name="SDK_HOME" value="" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/test/设计模式/简单工厂模式" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/test/算法" />
<option name="IS_MODULE_SDK" value="true" />
<option name="ADD_CONTENT_ROOTS" value="true" />
<option name="ADD_SOURCE_ROOTS" value="true" />
<EXTENSION ID="PythonCoverageRunConfigurationExtension" runner="coverage.py" />
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/test/设计模式/简单工厂模式/demo.py" />
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/test/算法/冒泡.py" />
<option name="PARAMETERS" value="" />
<option name="SHOW_COMMAND_LINE" value="false" />
<option name="EMULATE_TERMINAL" value="false" />
@@ -197,7 +187,7 @@
<option name="INPUT_FILE" value="" />
<method v="2" />
</configuration>
<configuration name="demo1" type="PythonConfigurationType" factoryName="Python" temporary="true" nameIsGenerated="true">
<configuration name="插入" type="PythonConfigurationType" factoryName="Python" temporary="true" nameIsGenerated="true">
<module name="tuoheng_alg" />
<option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" />
@@ -205,12 +195,12 @@
<env name="PYTHONUNBUFFERED" value="1" />
</envs>
<option name="SDK_HOME" value="" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/test/设计模式/简单工厂模式" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/test/算法" />
<option name="IS_MODULE_SDK" value="true" />
<option name="ADD_CONTENT_ROOTS" value="true" />
<option name="ADD_SOURCE_ROOTS" value="true" />
<EXTENSION ID="PythonCoverageRunConfigurationExtension" runner="coverage.py" />
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/test/设计模式/简单工厂模式/demo1.py" />
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/test/算法/插入.py" />
<option name="PARAMETERS" value="" />
<option name="SHOW_COMMAND_LINE" value="false" />
<option name="EMULATE_TERMINAL" value="false" />
@@ -219,7 +209,7 @@
<option name="INPUT_FILE" value="" />
<method v="2" />
</configuration>
<configuration name="demo3" type="PythonConfigurationType" factoryName="Python" temporary="true" nameIsGenerated="true">
<configuration name="选择" type="PythonConfigurationType" factoryName="Python" temporary="true" nameIsGenerated="true">
<module name="tuoheng_alg" />
<option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" />
@@ -227,12 +217,12 @@
<env name="PYTHONUNBUFFERED" value="1" />
</envs>
<option name="SDK_HOME" value="" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/test/元类" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/test/算法" />
<option name="IS_MODULE_SDK" value="true" />
<option name="ADD_CONTENT_ROOTS" value="true" />
<option name="ADD_SOURCE_ROOTS" value="true" />
<EXTENSION ID="PythonCoverageRunConfigurationExtension" runner="coverage.py" />
<option name="SCRIPT_NAME" value="D:\tuoheng\codenew\tuoheng_alg\test\设计模式\单例\demo3.py" />
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/test/算法/选择.py" />
<option name="PARAMETERS" value="" />
<option name="SHOW_COMMAND_LINE" value="false" />
<option name="EMULATE_TERMINAL" value="false" />
@@ -241,20 +231,20 @@
<option name="INPUT_FILE" value="" />
<method v="2" />
</configuration>
<configuration name="demo4" type="PythonConfigurationType" factoryName="Python" temporary="true" nameIsGenerated="true">
<configuration name="editImage" type="PythonConfigurationType" factoryName="Python" nameIsGenerated="true">
<module name="tuoheng_alg" />
<option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" />
<envs>
<env name="PYTHONUNBUFFERED" value="1" />
</envs>
<option name="SDK_HOME" value="" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/test/元类" />
<option name="IS_MODULE_SDK" value="true" />
<option name="SDK_HOME" value="$PROJECT_DIR$/../../../software/anaconda/envs/test/python.exe" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/test/editimage" />
<option name="IS_MODULE_SDK" value="false" />
<option name="ADD_CONTENT_ROOTS" value="true" />
<option name="ADD_SOURCE_ROOTS" value="true" />
<EXTENSION ID="PythonCoverageRunConfigurationExtension" runner="coverage.py" />
<option name="SCRIPT_NAME" value="D:\tuoheng\codenew\tuoheng_alg\test\设计模式\单例\demo4.py" />
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/test/editimage/editImage.py" />
<option name="PARAMETERS" value="" />
<option name="SHOW_COMMAND_LINE" value="false" />
<option name="EMULATE_TERMINAL" value="false" />
@@ -263,7 +253,7 @@
<option name="INPUT_FILE" value="" />
<method v="2" />
</configuration>
<configuration name="demo5" type="PythonConfigurationType" factoryName="Python" temporary="true" nameIsGenerated="true">
<configuration name="mysqltest" type="PythonConfigurationType" factoryName="Python" nameIsGenerated="true">
<module name="tuoheng_alg" />
<option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" />
@@ -271,34 +261,12 @@
<env name="PYTHONUNBUFFERED" value="1" />
</envs>
<option name="SDK_HOME" value="" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/test/元类" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/test" />
<option name="IS_MODULE_SDK" value="true" />
<option name="ADD_CONTENT_ROOTS" value="true" />
<option name="ADD_SOURCE_ROOTS" value="true" />
<EXTENSION ID="PythonCoverageRunConfigurationExtension" runner="coverage.py" />
<option name="SCRIPT_NAME" value="D:\tuoheng\codenew\tuoheng_alg\test\设计模式\单例\demo5.py" />
<option name="PARAMETERS" value="" />
<option name="SHOW_COMMAND_LINE" value="false" />
<option name="EMULATE_TERMINAL" value="false" />
<option name="MODULE_MODE" value="false" />
<option name="REDIRECT_INPUT" value="false" />
<option name="INPUT_FILE" value="" />
<method v="2" />
</configuration>
<configuration name="editImage" type="PythonConfigurationType" factoryName="Python" nameIsGenerated="true">
<module name="tuoheng_alg" />
<option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" />
<envs>
<env name="PYTHONUNBUFFERED" value="1" />
</envs>
<option name="SDK_HOME" value="$PROJECT_DIR$/../../../software/anaconda/envs/test/python.exe" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/test/editimage" />
<option name="IS_MODULE_SDK" value="false" />
<option name="ADD_CONTENT_ROOTS" value="true" />
<option name="ADD_SOURCE_ROOTS" value="true" />
<EXTENSION ID="PythonCoverageRunConfigurationExtension" runner="coverage.py" />
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/test/editimage/editImage.py" />
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/test/mysqltest.py" />
<option name="PARAMETERS" value="" />
<option name="SHOW_COMMAND_LINE" value="false" />
<option name="EMULATE_TERMINAL" value="false" />
@@ -307,7 +275,7 @@
<option name="INPUT_FILE" value="" />
<method v="2" />
</configuration>
<configuration name="mysqltest" type="PythonConfigurationType" factoryName="Python" nameIsGenerated="true">
<configuration name="test (1)" type="PythonConfigurationType" factoryName="Python" temporary="true" nameIsGenerated="true">
<module name="tuoheng_alg" />
<option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" />
@@ -315,12 +283,12 @@
<env name="PYTHONUNBUFFERED" value="1" />
</envs>
<option name="SDK_HOME" value="" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/test" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/test/语法/time" />
<option name="IS_MODULE_SDK" value="true" />
<option name="ADD_CONTENT_ROOTS" value="true" />
<option name="ADD_SOURCE_ROOTS" value="true" />
<EXTENSION ID="PythonCoverageRunConfigurationExtension" runner="coverage.py" />
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/test/mysqltest.py" />
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/test/语法/time/test.py" />
<option name="PARAMETERS" value="" />
<option name="SHOW_COMMAND_LINE" value="false" />
<option name="EMULATE_TERMINAL" value="false" />
@@ -329,21 +297,20 @@
<option name="INPUT_FILE" value="" />
<method v="2" />
</configuration>
<configuration name="test" type="PythonConfigurationType" factoryName="Python" temporary="true" nameIsGenerated="true">
<configuration name="test (2)" type="PythonConfigurationType" factoryName="Python" temporary="true" nameIsGenerated="true">
<module name="tuoheng_alg" />
<option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" />
<envs>
<env name="PYTHONUNBUFFERED" value="1" />
</envs>
<option name="SDK_HOME" value="B:\software\conda\envs\test\python.exe" />
<option name="SDK_NAME" value="Python 3.8 (test)" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/test/类型标注" />
<option name="IS_MODULE_SDK" value="false" />
<option name="SDK_HOME" value="" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/test/语法/datetime" />
<option name="IS_MODULE_SDK" value="true" />
<option name="ADD_CONTENT_ROOTS" value="true" />
<option name="ADD_SOURCE_ROOTS" value="true" />
<EXTENSION ID="PythonCoverageRunConfigurationExtension" runner="coverage.py" />
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/test/类型标注/test.py" />
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/test/语法/datetime/test.py" />
<option name="PARAMETERS" value="" />
<option name="SHOW_COMMAND_LINE" value="false" />
<option name="EMULATE_TERMINAL" value="false" />
@@ -355,19 +322,15 @@
<list>
<item itemvalue="Python.editImage" />
<item itemvalue="Python.mysqltest" />
<item itemvalue="Python.demo" />
<item itemvalue="Python.demo1" />
<item itemvalue="Python.demo3" />
<item itemvalue="Python.demo4" />
<item itemvalue="Python.demo5" />
<item itemvalue="Python.test (1)" />
<item itemvalue="Python.test (2)" />
<item itemvalue="Python.冒泡" />
</list>
<recent_temporary>
<list>
<item itemvalue="Python.demo1" />
<item itemvalue="Python.demo" />
<item itemvalue="Python.demo5" />
<item itemvalue="Python.demo4" />
<item itemvalue="Python.demo3" />
<item itemvalue="Python.冒泡" />
<item itemvalue="Python.test (2)" />
<item itemvalue="Python.test (1)" />
</list>
</recent_temporary>
</component>
@@ -535,7 +498,16 @@
<workItem from="1684456296559" duration="11147000" />
<workItem from="1684653340859" duration="1199000" />
<workItem from="1684715657250" duration="6747000" />
<workItem from="1684801865053" duration="7552000" />
<workItem from="1684801865053" duration="16900000" />
<workItem from="1684887585997" duration="21179000" />
<workItem from="1685069170536" duration="5199000" />
<workItem from="1685318330589" duration="16451000" />
<workItem from="1685367595669" duration="1105000" />
<workItem from="1685405545435" duration="5540000" />
<workItem from="1685929597469" duration="1586000" />
<workItem from="1686009758832" duration="4033000" />
<workItem from="1686099127317" duration="8648000" />
<workItem from="1686181421528" duration="587000" />
</task>
<servers />
</component>
@@ -576,6 +548,11 @@
<line>1</line>
<option name="timeStamp" value="5" />
</line-breakpoint>
<line-breakpoint enabled="true" suspend="THREAD" type="python-line">
<url>file://$PROJECT_DIR$/test/collections/deque.py</url>
<line>134</line>
<option name="timeStamp" value="6" />
</line-breakpoint>
</breakpoints>
</breakpoint-manager>
</component>
@@ -585,51 +562,64 @@
</component>
<component name="com.intellij.coverage.CoverageDataManagerImpl">
<SUITE FILE_PATH="coverage/tuoheng_alg$color_test.coverage" NAME="color_test 覆盖结果" MODIFIED="1683683775604" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/test/color" />
<SUITE FILE_PATH="coverage/tuoheng_alg$demo1.coverage" NAME="demo1 覆盖结果" MODIFIED="1684807129961" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/test/元类" />
<SUITE FILE_PATH="coverage/tuoheng_alg$demo1.coverage" NAME="demo1 覆盖结果" MODIFIED="1685325611032" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" />
<SUITE FILE_PATH="coverage/tuoheng_alg$ffmpeg33.coverage" NAME="ffmpeg33 覆盖结果" MODIFIED="1670489109246" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/test/ffmpeg11" />
<SUITE FILE_PATH="coverage/tuoheng_alg$demo4.coverage" NAME="demo4 覆盖结果" MODIFIED="1684809818971" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/test/元类" />
<SUITE FILE_PATH="coverage/tuoheng_alg$minio.coverage" NAME="minio 覆盖结果" MODIFIED="1667465702864" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/test/minio1" />
<SUITE FILE_PATH="coverage/tuoheng_alg$OrderedDict.coverage" NAME="OrderedDict 覆盖结果" MODIFIED="1684897161191" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/test/collections" />
<SUITE FILE_PATH="coverage/tuoheng_alg$3.coverage" NAME="视频添加文字水印3 Coverage Results" MODIFIED="1661906152928" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/test" />
<SUITE FILE_PATH="coverage/tuoheng_alg$SnakeGame.coverage" NAME="SnakeGame 覆盖结果" MODIFIED="1684825356565" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/test/游戏" />
<SUITE FILE_PATH="coverage/tuoheng_alg$wraps.coverage" NAME="wraps 覆盖结果" MODIFIED="1684913804419" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/test/偏函数" />
<SUITE FILE_PATH="coverage/tuoheng_alg$ffmpeg12.coverage" NAME="ffmpeg12 覆盖结果" MODIFIED="1675391366890" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/test/ffmpeg11" />
<SUITE FILE_PATH="coverage/tuoheng_alg$Test__2_.coverage" NAME="Test (2) 覆盖结果" MODIFIED="1681796501563" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/test/路径" />
<SUITE FILE_PATH="coverage/tuoheng_alg$test1.coverage" NAME="test1 覆盖结果" MODIFIED="1681988279624" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/test/cuda" />
<SUITE FILE_PATH="coverage/tuoheng_alg$test1.coverage" NAME="test1 覆盖结果" MODIFIED="1685341746877" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/test/序列化" />
<SUITE FILE_PATH="coverage/tuoheng_alg$ossdemo.coverage" NAME="ossdemo 覆盖结果" MODIFIED="1681715255761" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/test/aliyun" />
<SUITE FILE_PATH="coverage/tuoheng_alg$test__1_.coverage" NAME="test (1) 覆盖结果" MODIFIED="1684480106837" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/test/日志" />
<SUITE FILE_PATH="coverage/tuoheng_alg$Counter.coverage" NAME="Counter 覆盖结果" MODIFIED="1684894898737" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/test/collections" />
<SUITE FILE_PATH="coverage/tuoheng_alg$test__1_.coverage" NAME="test (1) 覆盖结果" MODIFIED="1685348439455" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/test/语法/time" />
<SUITE FILE_PATH="coverage/tuoheng_alg$aa1.coverage" NAME="aa1 覆盖结果" MODIFIED="1667351136888" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/test/ffmpeg11" />
<SUITE FILE_PATH="coverage/tuoheng_alg$singledispatch.coverage" NAME="singledispatch 覆盖结果" MODIFIED="1684912905741" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/test/偏函数" />
<SUITE FILE_PATH="coverage/tuoheng_alg___$test.coverage" NAME="test 覆盖结果" MODIFIED="1668577200259" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/test/while" />
<SUITE FILE_PATH="coverage/tuoheng_alg$editImage.coverage" NAME="editImage 覆盖结果" MODIFIED="1678348350574" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/test/editimage" />
<SUITE FILE_PATH="coverage/tuoheng_alg$2.coverage" NAME="协程2 覆盖结果" MODIFIED="1668066168428" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="/opt/tuo_heng/algSch/test/协程/" />
<SUITE FILE_PATH="coverage/tuoheng_alg$ImgBaiduSdk.coverage" NAME="ImgBaiduSdk 覆盖结果" MODIFIED="1678355024003" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/util" />
<SUITE FILE_PATH="coverage/tuoheng_alg$ImageUtils.coverage" NAME="ImageUtils Coverage Results" MODIFIED="1663499421253" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/util" />
<SUITE FILE_PATH="coverage/tuoheng_alg$demo2.coverage" NAME="demo2 覆盖结果" MODIFIED="1684808407865" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/test/元类" />
<SUITE FILE_PATH="coverage/tuoheng_alg$ChainMap.coverage" NAME="ChainMap 覆盖结果" MODIFIED="1684905474944" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/test/collections" />
<SUITE FILE_PATH="coverage/tuoheng_alg$dsp_master.coverage" NAME="dsp_master 覆盖结果" MODIFIED="1680503755624" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" />
<SUITE FILE_PATH="coverage/tuoheng_alg$IntelligentRecognitionProcess.coverage" NAME="IntelligentRecognitionProcess 覆盖结果" MODIFIED="1682651444560" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/concurrency" />
<SUITE FILE_PATH="coverage/tuoheng_alg$test.coverage" NAME="test 覆盖结果" MODIFIED="1684742307978" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/test/opencv" />
<SUITE FILE_PATH="coverage/tuoheng_alg$demo3.coverage" NAME="demo3 覆盖结果" MODIFIED="1684809071819" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/test/元类" />
<SUITE FILE_PATH="coverage/tuoheng_alg$test.coverage" NAME="test 覆盖结果" MODIFIED="1685342843175" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/test/语法/statistics_test" />
<SUITE FILE_PATH="coverage/tuoheng_alg$Test.coverage" NAME="Test 覆盖结果" MODIFIED="1683802532361" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/test/序列化" />
<SUITE FILE_PATH="coverage/tuoheng_alg$mysqltest.coverage" NAME="mysqltest Coverage Results" MODIFIED="1660868712851" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/test" />
<SUITE FILE_PATH="coverage/tuoheng_alg$asnyc__1_.coverage" NAME="asnyc (1) Coverage Results" MODIFIED="1663458917599" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/test" />
<SUITE FILE_PATH="coverage/tuoheng_alg$cv2test1.coverage" NAME="cv2test1 覆盖结果" MODIFIED="1665738045603" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="/home/DATA/chenyukun/algSch/test/" />
<SUITE FILE_PATH="coverage/tuoheng_alg$test2.coverage" NAME="test2 覆盖结果" MODIFIED="1669178077956" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/test/str" />
<SUITE FILE_PATH="coverage/tuoheng_alg$csv.coverage" NAME="csv 覆盖结果" MODIFIED="1685331143094" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/test/读写" />
<SUITE FILE_PATH="coverage/tuoheng_alg$ffmpeg22.coverage" NAME="aa 覆盖结果" MODIFIED="1667350492259" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="/opt/tuo_heng" />
<SUITE FILE_PATH="coverage/tuoheng_alg$aa.coverage" NAME="aa 覆盖结果" MODIFIED="1684461916527" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/test/ffmpeg11" />
<SUITE FILE_PATH="coverage/tuoheng_alg$cmp_to_key.coverage" NAME="cmp_to_key 覆盖结果" MODIFIED="1684910406140" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/test/偏函数" />
<SUITE FILE_PATH="coverage/tuoheng_alg$KafkaUtils__1_.coverage" NAME="KafkaUtils (1) Coverage Results" MODIFIED="1663464961001" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/util" />
<SUITE FILE_PATH="coverage/tuoheng_alg$__init____1_.coverage" NAME="__init__ (1) 覆盖结果" MODIFIED="1684918690445" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/test/偏函数" />
<SUITE FILE_PATH="coverage/tuoheng_alg$voddemo.coverage" NAME="voddemo 覆盖结果" MODIFIED="1681722102430" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/test/aliyun" />
<SUITE FILE_PATH="coverage/tuoheng_alg___$producer_start.coverage" NAME="producer_start 覆盖结果" MODIFIED="1668522825199" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="/home/thsw/chenyukun/algSch" />
<SUITE FILE_PATH="coverage/tuoheng_alg___$producer_start1.coverage" NAME="producer_start1 覆盖结果" MODIFIED="1668437822632" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="/home/thsw/chenyukun/algSch/test/kafka" />
<SUITE FILE_PATH="coverage/tuoheng_alg$re.coverage" NAME="re 覆盖结果" MODIFIED="1684221962919" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/test/正则" />
<SUITE FILE_PATH="coverage/tuoheng_alg$deque.coverage" NAME="deque 覆盖结果" MODIFIED="1684896079231" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/test/collections" />
<SUITE FILE_PATH="coverage/tuoheng_alg$producer_start__1_.coverage" NAME="producer_start (1) 覆盖结果" MODIFIED="1665832569996" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/test" />
<SUITE FILE_PATH="coverage/tuoheng_alg___$ffmpeg11.coverage" NAME="ffmpeg11 覆盖结果" MODIFIED="1668410004435" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/test/ffmpeg11" />
<SUITE FILE_PATH="coverage/tuoheng_alg$demo.coverage" NAME="demo 覆盖结果" MODIFIED="1684810722320" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/test/设计模式/简单工厂模式" />
<SUITE FILE_PATH="coverage/tuoheng_alg$__init__.coverage" NAME="__init__ 覆盖结果" MODIFIED="1684908678532" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/test/collections" />
<SUITE FILE_PATH="coverage/tuoheng_alg$demo.coverage" NAME="demo 覆盖结果" MODIFIED="1685071079173" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/test/语法/list" />
<SUITE FILE_PATH="coverage/tuoheng_alg$producer_start.coverage" NAME="producer_start1 覆盖结果" MODIFIED="1670999187123" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/test/kafka" />
<SUITE FILE_PATH="coverage/tuoheng_alg$test__3_.coverage" NAME="test (3) 覆盖结果" MODIFIED="1684802056733" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/test/设计模式/单例" />
<SUITE FILE_PATH="coverage/tuoheng_alg$numpy_test.coverage" NAME="numpy_test 覆盖结果" MODIFIED="1684205019028" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/test/numpy" />
<SUITE FILE_PATH="coverage/tuoheng_alg$.coverage" NAME="协程笔记 覆盖结果" MODIFIED="1680926972744" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/test/协程" />
<SUITE FILE_PATH="coverage/tuoheng_alg$namedtuple.coverage" NAME="namedtuple 覆盖结果" MODIFIED="1684898422076" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/test/collections" />
<SUITE FILE_PATH="coverage/tuoheng_alg$.coverage" NAME="冒泡 覆盖结果" MODIFIED="1685368101589" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/test/算法" />
<SUITE FILE_PATH="coverage/tuoheng_alg$4.coverage" NAME="视频添加图片水印4 Coverage Results" MODIFIED="1661874731395" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/test" />
<SUITE FILE_PATH="coverage/tuoheng_alg$gputest.coverage" NAME="gputest 覆盖结果" MODIFIED="1681950938970" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/test/gpu" />
<SUITE FILE_PATH="coverage/tuoheng_alg$1.coverage" NAME="协程1 覆盖结果" MODIFIED="1667866542122" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/test/协程" />
<SUITE FILE_PATH="coverage/tuoheng_alg___$3.coverage" NAME="协程3 覆盖结果" MODIFIED="1668147029048" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/test/协程" />
<SUITE FILE_PATH="coverage/tuoheng_alg$AliyunSdk.coverage" NAME="AliyunSdk 覆盖结果" MODIFIED="1683803902993" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" />
<SUITE FILE_PATH="coverage/tuoheng_alg$1.coverage" NAME="全局变量1 覆盖结果" MODIFIED="1685322476342" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/test/语法" />
<SUITE FILE_PATH="coverage/tuoheng_alg$csv_test__1_.coverage" NAME="csv_test (1) 覆盖结果" MODIFIED="1685331476413" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/test/读写" />
<SUITE FILE_PATH="coverage/tuoheng_alg$asnyc.coverage" NAME="asnyc Coverage Results" MODIFIED="1663459033435" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/test" />
<SUITE FILE_PATH="coverage/tuoheng_alg$5.coverage" NAME="视频添加图片水印5 Coverage Results" MODIFIED="1661905982885" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/test" />
<SUITE FILE_PATH="coverage/tuoheng_alg$read.coverage" NAME="read Coverage Results" MODIFIED="1663640070956" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/test" />
@@ -637,11 +627,13 @@
<SUITE FILE_PATH="coverage/tuoheng_alg$TimeUtils.coverage" NAME="TimeUtils Coverage Results" MODIFIED="1661222768678" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/util" />
<SUITE FILE_PATH="coverage/tuoheng_alg$producer_start1.coverage" NAME="producer_start1 覆盖结果" MODIFIED="1671428635702" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/test/kafka" />
<SUITE FILE_PATH="coverage/tuoheng_alg$demo5.coverage" NAME="demo5 覆盖结果" MODIFIED="1684810002359" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/test/元类" />
<SUITE FILE_PATH="coverage/tuoheng_alg$demo__1_.coverage" NAME="demo (1) 覆盖结果" MODIFIED="1685086704735" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/test/语法/for" />
<SUITE FILE_PATH="coverage/tuoheng_alg___$producer_stop.coverage" NAME="producer_stop 覆盖结果" MODIFIED="1668522920533" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="/home/thsw/chenyukun/algSch" />
<SUITE FILE_PATH="coverage/tuoheng_alg$Test__1_.coverage" NAME="Test (1) 覆盖结果" MODIFIED="1683865962957" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/test/线程" />
<SUITE FILE_PATH="coverage/tuoheng_alg$pa.coverage" NAME="pa 覆盖结果" MODIFIED="1684217734590" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/test/pachong" />
<SUITE FILE_PATH="coverage/tuoheng_alg$defaultdict.coverage" NAME="defaultdict 覆盖结果" MODIFIED="1684900122612" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/test/collections" />
<SUITE FILE_PATH="coverage/tuoheng_alg$ffmpeg13.coverage" NAME="ffmpeg13 覆盖结果" MODIFIED="1675394160900" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/test/ffmpeg11" />
<SUITE FILE_PATH="coverage/tuoheng_alg$KafkaUtils.coverage" NAME="KafkaUtils Coverage Results" MODIFIED="1663465345491" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/util" />
<SUITE FILE_PATH="coverage/tuoheng_alg$test__2_.coverage" NAME="test (2) 覆盖结果" MODIFIED="1684743889711" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/test/类型标注" />
<SUITE FILE_PATH="coverage/tuoheng_alg$test__2_.coverage" NAME="test (2) 覆盖结果" MODIFIED="1685349340367" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/test/语法/datetime" />
</component>
</project>

+ 130
- 0
demo1.py View File

@@ -0,0 +1,130 @@
# -*- coding: utf-8 -*-
import datetime
import time

import json

from aliyunsdkcore.client import AcsClient
from aliyunsdkvod.request.v20170321 import GetPlayInfoRequest
from loguru import logger

from vodsdk.AliyunVodUploader import AliyunVodUploader
from vodsdk.UploadVideoRequest import UploadVideoRequest
'''
视频上传使用vod
1. 阿里云VOD文档地址:https://help.aliyun.com/product/29932.html?spm=5176.8413026.J_3895079540.5.1b4a1029mXvncc
2. 阿里云对象存储OSS SDK示例地址:https://help.aliyun.com/document_detail/64148.html?spm=a2c4g.64148.0.0.5ae54150jUecEU
4. 安装SDK:
python -m pip install aliyun-python-sdk-core -i https://pypi.tuna.tsinghua.edu.cn/simple
python -m pip install aliyun-python-sdk-live -i https://pypi.tuna.tsinghua.edu.cn/simple
python -m pip install aliyun-python-sdk-core-v3 -i https://pypi.tuna.tsinghua.edu.cn/simple
python -m pip install aliyun-python-sdk-vod -i https://pypi.tuna.tsinghua.edu.cn/simple
python -m pip install alibabacloud_vod20170321 -i https://pypi.tuna.tsinghua.edu.cn/simple
python -m pip install oss2 -i https://pypi.tuna.tsinghua.edu.cn/simple
5. 视频域名地址:https://vod.play.t-aaron.com/
'''


class AliyunVodSdk:

def __init__(self, requestId):
self.__client = None
self.__access_key = 'LTAI5tMiefafZ6br4zmrQWv9'
self.__access_secret = 'JgzQjSCkwZ7lefZO6egOArw38YH1Tk'
self.__regionId = "cn-shanghai"
self.__cateId = '1000468340'
self.__requestId = requestId

def init_vod_client(self):
return AcsClient(self.__access_key, self.__access_secret, self.__regionId, auto_retry=True, max_retry_time=3, timeout=30)

'''
根据videoId获取视频地址
'''

def get_play_info(self, videoId):
logger.info("开始获取视频地址,videoId:{}", videoId)
start = time.time()
while True:
try:
clt = self.init_vod_client()
request = GetPlayInfoRequest.GetPlayInfoRequest()
request.set_accept_format('JSON')
request.set_VideoId(videoId)
request.set_AuthTimeout(3600 * 5)
response = json.loads(clt.do_action_with_exception(request))
play_url = response["PlayInfoList"]["PlayInfo"][0]["PlayURL"]
logger.info("获取视频地址成功,视频地址: {}", play_url)
return play_url
except Exception as e:
logger.error("获取视频地址失败,5秒后重试, requestId: {}")
time.sleep(5)
current_time = time.time()
if "HTTP Status: 403" not in str(e):
logger.exception("获取视频地址失败: {}", e)
raise e
if "HTTP Status: 403" in str(e) and ("UploadFail" in str(e) or "TranscodeFail" in str(e)):
logger.exception("获取视频地址失败: {}", e)
raise e
diff_time = current_time - start
if diff_time > 60 * 60 * 5:
logger.exception("获取视频地址失败超时异常: {},超时时间:{}", str(e), diff_time)
raise e

def upload_local_video(self, filePath, file_title, storageLocation=None):
logger.info("开始执行vod视频上传, filePath: {}", filePath)
uploader = AliyunVodUploader(self.__access_key, self.__access_secret, self.__requestId)
uploadVideoRequest = UploadVideoRequest(filePath, file_title)
uploadVideoRequest.setCateId(self.__cateId)
if storageLocation:
uploadVideoRequest.setStorageLocation(storageLocation)
MAX_RETRIES = 3
retry_count = 0
while True:
try:
result = uploader.uploadLocalVideo(uploadVideoRequest)
logger.info("vod视频上传成功, videoId:{}", result.get("VideoId"))
return result.get("VideoId")
except Exception as e:
retry_count += 1
time.sleep(1)
logger.error("vod视频上传失败,重试次数:{}", retry_count)
if retry_count >= MAX_RETRIES:
logger.exception("vod视频上传重试失败: {}", str(e))
raise e


YY_MM_DD_HH_MM_SS = "%Y-%m-%d %H:%M:%S"
YMDHMSF = "%Y%m%d%H%M%S%f"


def generate_timestamp():
"""根据当前时间获取时间戳,返回整数"""
return int(time.time())


def now_date_to_str(fmt=None):
if fmt is None:
fmt = YY_MM_DD_HH_MM_SS
return datetime.datetime.now().strftime(fmt)


if __name__ == "__main__":
# 本地原视频命名
random_time = now_date_to_str(YMDHMSF)
# # 如果是离线视频,将 _on_or_ 替换为 _off_or_
# orFilePath = "%s%s%s%s%s" % ('本地路径', random_time, "_on_or_", 'requestId', ".mp4")
# # 本地AI识别后的视频命名
# # 如果是离线视频,将 _on_ai_ 替换为 _off_ai_
# aiFilePath = "%s%s%s%s%s" % ('本地路径', random_time, "_on_ai_", 'requestId', ".mp4")
# filePath = "%s%s%s%s%s" % ('D:\\shipin\\', random_time, "_on_ai_", '11111111', ".mp4")
filePath = 'D:\\shipin\\111.mp4'
codClinet = AliyunVodSdk("1111111")
result = codClinet.upload_local_video(filePath, 'aiOnLineVideo')
print(result)
url = codClinet.get_play_info(result)
print(url)





BIN
test/__pycache__/__init__.cpython-38.pyc View File


+ 55
- 0
test/collections/ChainMap.py View File

@@ -0,0 +1,55 @@



"""
1、ChainMap是什么
ChainMap最基本的使用,可以用来合并两个或者更多个字典,当查询的时候,从前往后依次查询。
ChainMap:将多个字典视为一个,解锁Python超能力。
ChainMap是由Python标准库提供的一种数据结构,允许你将多个字典视为一个。换句话说:ChainMap是一个基于多dict的可更新的视图,它的行为就像一个普通的dict。
ChainMap类用于快速链接多个映射,以便将它们视为一个单元。它通常比创建新字典和多次调用update()快得多。
你以前可能从来没有听说过ChainMap,你可能会认为ChainMap的使用情况是非常特定的。坦率地说,你是对的。
我知道的用例包括:
通过多个字典搜索
提供链缺省值
经常计算字典子集的性能关键的应用程序
2、特性
1)找到一个就不找了:这个列表是按照第一次搜索到最后一次搜索的顺序组织的,搜索查询底层映射,直到一个键被找到。
2)更新原始映射:不同的是,写,更新和删除只操作第一个映射。
3)支持所有常用字典方法。
简而言之ChainMap:将多个字典视为一个,解锁Python超能力。
Python标准库中的集合模块包含许多为性能而设计的实用的数据结构。著名的包括命名元组或计数器。
今天,通过实例,我们来看看鲜为人知的ChainMap。通过浏览具体的示例,我希望给你一个提示,关于在更高级的Python工作中使用ChainMap将如何从中受益。
"""

from collections import ChainMap
baseline = {'music': 'bach', 'art': 'rembrandt'}
adjustments = {'art': 'van gogh', 'opera': 'carmen'}
test = ChainMap(adjustments, baseline)
print(test)
test1 = list(ChainMap(adjustments, baseline))
print(test1)
# 存在重复元素时,也不会去重
dcic1 = {'label1': '11', 'label2': '22'}
dcic2 = {'label2': '22', 'label3': '33'}
dcic3 = {'label4': '44', 'label5': '55'}
last = ChainMap(dcic1, dcic2, dcic3)
print(last)
print(last['label2'])

"""
new_child()方法
用法:new_child(m=None)
返回一个新的ChainMap类,包含了一个新映射(map),后面跟随当前实例的全部映射map。
如果m被指定,它就成为不同新的实例,就是在所有映射前加上 m,如果没有指定,就加上一个空字典,
这样的话一个 d.new_child() 调用等价于ChainMap({}, *d.maps) 。这个方法用于创建子上下文,不改变任何父映射的值。
"""
aa = last.new_child(m={'key_new': 888})
print(aa)

"""
parents属性
属性返回一个新的ChainMap包含所有的当前实例的映射,除了第一个。
这样可以在搜索的时候跳过第一个映射。使用的场景类似在 nested scopes 嵌套作用域中使用nonlocal关键词。
用例也可以类比内建函数super() 。一个d.parents 的引用等价于ChainMap(*d.maps[1:])。
"""
print(aa.parents)

+ 111
- 0
test/collections/Counter.py View File

@@ -0,0 +1,111 @@
import collections
import re
from collections import Counter

print(collections.__all__)
"""
['deque', 'defaultdict', 'namedtuple', 'UserDict', 'UserList',
'UserString', 'Counter', 'OrderedDict', 'ChainMap']
这个模块实现了特定目标的容器,以提供Python标准内建容器dict , list , set , 和tuple 的替代选择。
deque: 类似列表(list)的容器,实现了在两端快速添加(append)和弹出(pop)
defaultdict: 字典的子类,提供了一个工厂函数,为字典查询提供一个默认值
namedtuple(): 创建命名元组子类的工厂函数,生成可以使用名字来访问元素内容的tuple子类
UserDict: 封装了字典对象,简化了字典子类化
UserList: 封装了列表对象,简化了列表子类化
UserString: 封装了字符串对象,简化了字符串子类化(中文版翻译有误)
Counter: 字典的子类,提供了可哈希对象的计数功能
OrderedDict: 字典的子类,保存了他们被添加的顺序,有序字典
ChainMap: 类似字典(dict)的容器类,将多个映射集合到一个视图里面
"""

text = 'remove an existing key one level down remove an existing key one level down'
# \w 匹配非特殊字符,即a-z、A-Z、0-9、_、汉字
words = re.findall(r'\w+', text)
print(Counter(words).most_common(10))

#计算列表中单词的个数
cnt = Counter()
for word in ['red', 'blue', 'red', 'green', 'blue', 'blue']:
cnt[word] += 1
print(cnt)

# #上述这样计算有点嘛,下面的方法更简单,直接计算就行
L = ['red', 'blue', 'red', 'green', 'blue', 'blue']
print(Counter(L))

# 元素从一个iterable 被计数或从其他的mapping (or counter)初始化:
# 字符串计数
print(Counter('gallahad'))

# 字典计数
print(Counter({'red': 4, 'blue': 2}))

# 是个啥玩意计数
print(Counter(cats=4, dogs=8))

"""
1、elements()
描述:返回一个迭代器,其中每个元素将重复出现计数值所指定次。 元素会按首次出现的顺序返回。 如果一个元素的计数值小于1,elements() 将会忽略它。
语法:elements( )
参数:无
"""
c = Counter(a=4, b=2, c=0, d=-2)
print(c)
print(list(c.elements()))
print(sorted(c.elements()))
c = Counter(a=4, b=2, c=0, d=5)
print(list(c.elements()))

"""
2、most_common()
返回一个列表,其中包含n个最常见的元素及出现次数,按常见程度由高到低排序。
如果n被省略或为None,most_common() 将返回计数器中的所有元素,
计数值相等的元素按首次出现的顺序排序,经常用来计算top词频的词语。
"""
print(Counter('abracadabra').most_common(3))
print(Counter('abracadabra').most_common(5))

"""
3、subtract()
从迭代对象或映射对象减去元素。像dict.update() 但是是减去,而不是替换。输入和输出都可以是0或者负数。
"""
c = Counter(a=4, b=2, c=0, d=-2)
d = Counter(a=1, b=2, c=3, d=4)
c.subtract(d)
print(c)

#减去一个abcd
str0 = Counter('aabbccdde')
str0.subtract('abcd')
print(str0)

"""
4、字典方法
通常字典方法都可用于Counter对象,除了有两个方法工作方式与字典并不相同。
fromkeys(iterable)
这个类方法没有在Counter中实现。
update([iterable-or-mapping])
从迭代对象计数元素或者从另一个映射对象 (或计数器) 添加。 像 dict.update() 但是是加上,而不是替换。
另外,迭代对象应该是序列元素,而不是一个 (key, value) 对。
"""
c = Counter(a=4, b=2, c=0, d=-2)
print(sum(c.values()))
print(list(c))
print(set(c))
print(dict(c))
print(c.items())
print(+c) # 删除零计数和负计数
c.clear()
print(c)
"""
5、数学操作
这个功能非常强大,提供了几个数学操作,可以结合 Counter 对象,以生产 multisets (计数器中大于0的元素)。
加和减,结合计数器,通过加上或者减去元素的相应计数。交集和并集返回相应计数的最小或最大值。
每种操作都可以接受带符号的计数,但是输出会忽略掉结果为零或者小于零的计数。
"""
c = Counter(a=3, b=1)
d = Counter(a=1, b=2)
print(c+d)
print(c - d)
print(c & d)
print(c | d)

+ 35
- 0
test/collections/OrderedDict.py View File

@@ -0,0 +1,35 @@
from collections import OrderedDict


"""
1、popitem
语法:popitem(last=True)
功能:有序字典的 popitem() 方法移除并返回一个 (key, value) 键值对。
如果 last 值为真,则按 LIFO 后进先出的顺序返回键值对,否则就按 FIFO 先进先出的顺序返回键值对。
"""
d = OrderedDict.fromkeys('abcde')
print(d)
print(d.popitem())
# #last=False时,弹出第一个
print(d.popitem(last=False))
print(d.popitem(last=True))

"""
2、move_to_end
"""
d = OrderedDict.fromkeys('abcde')
d.move_to_end('b')
print(d)
d.move_to_end('b', last=False)
print(d)

"""
3、reversed()
相对于通常的映射方法,有序字典还另外提供了逆序迭代的支持,通过reversed()。
"""
d = OrderedDict.fromkeys('acbde')
print(d)
print(list(reversed(d)))

c = OrderedDict({'a': 1, 'c': 2, 'b': 3})
print(c)

+ 30
- 0
test/collections/__init__.py View File

@@ -0,0 +1,30 @@
# import collections
#
# print(collections.__all__)
# print(dir(collections))
#
# d = {}
# d.setdefault(2, []).append(23)
# d.setdefault(2, []).append(11)
# print(d)
# d.setdefault(2, []).append(23)
#
# # 定义一个curry风格函数
# x = lambda y: [
# print(y),
# print("..."),
# x
# ][-1]
# print(x(1)(2))
#
# import heapq
# print(heapq.nlargest(1, [
# {'S': 5, 'H': 3},
# {'S': 7, 'H': 1},
# {'S': 0, 'H': 2}
# ], key=lambda x: x['S']))
#
# s = [1, [2, [3, [4, [5, 6], 7], 8], (9, 0)]]
# f = lambda x: [y for _x in x for y in f(_x)] if isinstance(x, (list, tuple)) else [x]
#
# print(f(s)) # [1, 2, 3, 4, 5, 6, 7, 8, 9, 0]

+ 66
- 0
test/collections/defaultdict.py View File

@@ -0,0 +1,66 @@


"""
默认字典-defaultdict
在Python字典中收集数据通常是很有用的。
在字典中获取一个 key 有两种方法, 第一种 get , 第二种 通过 [] 获取.
使用dict时,如果引用的Key不存在,就会抛出KeyError。如果希望key不存在时,返回一个默认值,就可以用defaultdict。
当我使用普通的字典时,用法一般是dict={},添加元素的只需要dict[element] =value即,调用的时候也是如此,
dict[element] = xxx,但前提是element字典里,如果不在字典里就会报错
这时defaultdict就能排上用场了,defaultdict的作用是在于,当字典里的key不存在但被查找时,
返回的不是keyError而是一个默认值,这个默认值是什么呢,下面会说

1、基础介绍
defaultdict([default_factory[, ...]])
返回一个新的类似字典的对象。 defaultdict是内置dict类的子类。它重载了一个方法并添加了一个可写的实例变量。
其余的功能与dict类相同,此处不再重复说明。
本对象包含一个名为default_factory的属性,构造时,第一个参数用于为该属性提供初始值,默认为 None。
所有其他参数(包括关键字参数)都相当于传递给 dict 的构造函数。
defaultdict 对象除了支持标准 dict 的操作,还支持以下方法作为扩展:
__missing__(key)
如果 default_factory 属性为 None,则调用本方法会抛出 KeyError 异常,附带参数 key。
如果 default_factory 不为 None,则它会被(不带参数地)调用来为 key 提供一个默认值,
这个值和 key 作为一对键值对被插入到字典中,并作为本方法的返回值返回。
如果调用 default_factory 时抛出了异常,这个异常会原封不动地向外层传递。
在无法找到所需键值时,本方法会被 dict 中的 __getitem__() 方法调用。
无论本方法返回了值还是抛出了异常,都会被 __getitem__() 传递。
注意,__missing__() 不会 被 __getitem__() 以外的其他方法调用。
意味着 get() 会像正常的 dict 那样返回 None,而不是使用 default_factory。
"""
from collections import defaultdict

"""
2、示例介绍
使用 list 作为 default_factory,很轻松地将(键-值对组成的)序列转换为(键-列表组成的)字典
"""
s = [('yellow', 1), ('blue', 2), ('yellow', 3), ('blue', 4), ('red', 1)]
d = defaultdict(list)
for k, v in s:
d[k].append(v)
print(sorted(d.items()))

"""
当每个键第一次遇见时,它还没有在字典里面,所以自动创建该条目,即调用default_factory方法,
返回一个空的 list。 list.append() 操作添加值到这个新的列表里。当再次存取该键时,就正常操作,list.append()
添加另一个值到列表中。这个计数比它的等价方法dict.setdefault()要快速和简单:
"""
s = [('yellow', 1), ('blue', 2), ('yellow', 3), ('blue', 4), ('red', 1)]
d = {}
for k, v in s:
d.setdefault(k, []).append(v)
print(sorted(d.items()))
# 设置 default_factory为int,使defaultdict用于计数(类似其他语言中的 bag或multiset):
s = 'mississippi'
d = defaultdict(int)
for k in s:
d[k] += 1
print(sorted(d.items()))

# 设置 default_factory 为 set 使 defaultdict 用于构建 set 集合:
s = [('red', 1), ('blue', 2), ('red', 3), ('blue', 4), ('red', 1), ('blue', 4)]
d = defaultdict(set)
for k, v in s:
d[k].add(v)
print(sorted(d.items()))
print(d['aaa'])


+ 148
- 0
test/collections/deque.py View File

@@ -0,0 +1,148 @@

"""
deque
双端队列,可以快速的从另外一侧追加和推出对象,deque是一个双向链表,
针对list连续的数据结构插入和删除进行优化。它提供了两端都可以操作的序列,
这表示在序列的前后你都可以执行添加或删除操作。双向队列(deque)对象支持以下方法:
"""
from collections import deque

"""
1、append()
添加 x 到右端。
"""
d = deque('ghi')
d.append('j')
print(d)

"""
2、appendleft()
添加 x 到左端。
"""
d.appendleft('f')
print(d)

"""
3、clear()
移除所有元素,使其长度为0.
"""
d = deque('ghi')
d.clear()
print(d)

"""
4、copy()
创建一份浅拷贝。
"""
d = deque('xiaoweuge')
y = d.copy()
print(y)

"""
5、count()
计算 deque 中元素等于 x 的个数。
"""
d = deque('xiaoweuge-shuai')
print(d.count('a'))

"""
6、extend()
扩展deque的右侧,通过添加iterable参数中的元素。
"""
a = deque('abc')
b = deque('cd')
a.extend(b)
print(a)

#与append 的区别
a = deque('abc')
b = deque('cd')
a.append(b)
print(a)

"""
7、extendleft()
扩展deque的左侧,通过添加iterable参数中的元素。注意,左添加时,在结果中iterable参数中的顺序将被反过来添加。
"""
a = deque('abc')
b = deque('cd')
a.extendleft(b)
print(a)

"""
8、index()
返回 x 在 deque 中的位置(在索引 start 之后,索引 stop 之前)。 返回第一个匹配项,如果未找到则引发 ValueError。
"""
d = deque('xiaoweuge')
print(d.index('w'))

"""
9、insert()
在位置 i 插入 x 。
如果插入会导致一个限长 deque 超出长度 maxlen 的话,就引发一个 IndexError。
"""
a = deque('abc')
a.insert(1, 'X')
print(a)

"""
10、pop()
移去并且返回一个元素,deque 最右侧的那一个。 如果没有元素的话,就引发一个 IndexError。
"""
d = deque('abc')
print(d.pop())

"""
11、popleft()
移去并且返回一个元素,deque 最左侧的那一个。 如果没有元素的话,就引发 IndexError。
"""
d = deque('abc')
print(d.popleft())

"""
12、remove(value)
移除找到的第一个 value。 如果没有的话就引发 ValueError。
"""
a = deque('abca')
a.remove('a')
print(a)

"""
13、reverse()
将deque逆序排列。返回 None 。
"""
#逆序排列
d = deque('ghi') # 创建一个deque
print(list(reversed(d)))

"""
14、rotate(n=1)
向右循环移动 n 步。 如果 n 是负数,就向左循环。
如果deque不是空的,向右循环移动一步就等价于 d.appendleft(d.pop()) , 向左循环一步就等价于 d.append(d.popleft()) 。
"""
# 向右边挤一挤
d = deque('ghijkl')
d.rotate(1)
print(d)

# 向左边挤一挤
d.rotate(-1)
print(d)

#看一个更明显的
x = deque('12345')
x.rotate()
print(x)

d = deque(['12',' av', 'cd'])
d.rotate(1)
print(d)

"""
15、maxlen
Deque的最大尺寸,如果没有限定的话就是 None 。
"""
d=deque(maxlen=10)
for i in range(20):
d.append(i)
print(d)

+ 83
- 0
test/collections/namedtuple.py View File

@@ -0,0 +1,83 @@


from collections import namedtuple

"""
可命名元组-namedtuple
生成可以使用名字来访问元素内容的tuple子类,命名元组赋予每个位置一个含义,提供可读性和自文档性。
它们可以用于任何普通元组,并添加了通过名字获取值的能力,通过索引值也是可以的。
1、参数介绍
namedtuple(typename,field_names,*,verbose=False, rename=False, module=None)
1)typename:该参数指定所创建的tuple子类的类名,相当于用户定义了一个新类。
2)field_names:该参数是一个字符串序列,如 ['x','y']。此外,field_names 也可直接使用单个字符串代表所有字段名,多个字段名用空格、逗号隔开,如 'x y' 或 'x,y'。任何有效的 Python 标识符都可作为字段名(不能以下画线开头)。有效的标识符可由字母、数字、下画线组成,但不能以数字、下面线开头,也不能是关键字(如 return、global、pass、raise 等)。
3)rename:如果将该参数设为 True,那么无效的字段名将会被自动替换为位置名。例如指定 ['abc','def','ghi','abc'],它将会被替换为 ['abc', '_1','ghi','_3'],这是因为 def 字段名是关键字,而 abc 字段名重复了。
4)verbose:如果该参数被设为 True,那么当该子类被创建后,该类定义就被立即打印出来。
5)module:如果设置了该参数,那么该类将位于该模块下,因此该自定义类的 __module__ 属性将被设为该参数值。
"""
# 定义命名元组类:Point
Point = namedtuple('Point', ['x', 'y'])
# 初始化Point对象,即可用位置参数,也可用命名参数
p = Point(11, y=22)
# 像普通元组一样用根据索引访问元素
print(p[0] + p[1])

#执行元组解包,按元素的位置解包
a, b = p
print(a, b)

#根据字段名访问各元素
print(p.x + p.y)
print(p)

"""
备注: 在Python中,带有前导下划线的方法通常被认为是“私有的”。
但是,namedtuple提供的其他方法(如._asdict()、._make()、._replace()等)是公开的。
除了继承元组的方法,命名元组还支持三个额外的方法和两个属性。为了防止字段名冲突,方法和属性以下划线开始。
"""
"""
_make(iterable)
类方法从存在的序列或迭代实例创建一个新实例。
"""
t = [14, 55]
print(Point._make(t))

"""
_asdict()
返回一个新的dict ,它将字段名称映射到它们对应的值:
"""
p = Point(x=11, y=22)
print(p._asdict())

"""
_replace(**kwargs)
返回一个新的命名元组实例,并将指定域替换为新的值
"""
p = Point(x=11, y=22)
p._replace(x=33)
print(p._replace(x=33))

"""
两个属性
_fields
字符串元组列出了字段名。用于提醒和从现有元组创建一个新的命名元组类型。
"""
print(p._fields)

Color = namedtuple('Color', 'red green blue')
Pixel = namedtuple('Pixel', Point._fields + Color._fields)
print(Pixel._fields)

"""
_field_defaults
字典将字段名称映射到默认值。
"""

Account = namedtuple('Account', ['type', 'balance'], defaults=[0])
print(Account._field_defaults)
print(Account('premium'))

"""
getattr()
要获取这个名字域的值,使用 getattr() 函数 :
"""
print(getattr(p, 'x'))

+ 0
- 0
test/cpu/__init__.py View File


+ 44
- 0
test/cpu/test.py View File

@@ -0,0 +1,44 @@
import platform
import subprocess
import fileinput


def get_mac_cpu_speed():
commond = 'system_profiler SPHardwareDataType | grep "Processor Speed" | cut -d ":" -f2'
proc = subprocess.Popen([commond], shell=True, stdout=subprocess.PIPE)
output = proc.communicate()[0]
output = output.decode() # bytes 转str
speed = output.lstrip().rstrip('\n')
return speed


def get_linux_cpu_speed():
for line in fileinput.input('/proc/cpuinfo'):
if 'MHz' in line:
value = line.split(':')[1].strip()
value = float(value)
speed = round(value / 1024, 1)
return "{speed} GHz".format(speed=speed)


def get_windows_cpu_speed():
import winreg
key = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, r"HARDWARE\DESCRIPTION\System\CentralProcessor\0")
speed, type = winreg.QueryValueEx(key, "~MHz")
speed = round(float(speed)/1024, 1)
return "{speed} GHz".format(speed=speed)


def get_cpu_speed():
osname = platform.system() # 获取操作系统的名称
speed = ''
if osname == "Darwin":
speed = get_mac_cpu_speed()
if osname == "Linux":
speed = get_linux_cpu_speed()
if osname in ["Windows", "Win32"]:
speed = get_windows_cpu_speed()

return speed

print(get_cpu_speed())

+ 0
- 0
test/ip/__init__.py View File


+ 34
- 0
test/ip/test.py View File

@@ -0,0 +1,34 @@
import socket

# def get_local_ip():
# client = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
# # 连接谷歌的dns服务器
# client.connect(("8.8.8.8", 80))
# ip, _ = client.getsockname() # 获取套接字自己的地址,返回元组,ip地址和端口号
# client.close()
# return ip
#
#
# if __name__ == '__main__':
# print(get_local_ip())


import socket
from concurrent.futures import wait, ALL_COMPLETED, ThreadPoolExecutor


def getport(port):
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.settimeout(1)
state = sock.connect_ex(("192.168.11.8", port))
if 0 == state:
print("port: {} is open".format(port))
sock.close()


with ThreadPoolExecutor(max_workers=100) as t:
task_array = []
for port in range(1, 65535):
task = t.submit(getport, port)
task_array.append(task)
wait(task_array, return_when=ALL_COMPLETED)

+ 0
- 0
test/os/__init__.py View File


+ 15
- 0
test/os/test.py View File

@@ -0,0 +1,15 @@
"""
1.os.rename(原文件名,新的文件名) ——文件重命名
2.os.remove(文件名) ——删除文件
如果不说明路径,则在源代码所在文件夹下寻找,寻找不到会报错。
若想删除指定文件夹下的文件,文件名则需要具体路径,例如 os.remove(r"D:\test_1\文件名"), r防止斜杠发生转义
3.os.mkdir(文件夹名) ——创建文件夹
4.os.rmdir(文件夹名) ——删除文件夹
5.os.getced() ——获取当前目录
6.os.chdir(目录) ——切换目录
7.os.listdir(目录) ——获取当前文件夹下所有的文件或者文件夹,返回一个列表
os.listdir("aa") #获取aa文件夹下的所有文件或文件夹,返回一个列表


"""
import os

+ 0
- 0
test/wifi/__init__.py View File


+ 9
- 0
test/wifi/test.py View File

@@ -0,0 +1,9 @@
import subprocess

result = subprocess.check_output(['netsh', 'wlan', 'show', 'network'])
result = result.decode('gbk')
lst = result.split('\r\n')
lst = lst[4:]
for index in range(len(lst)):
if index % 5 == 0:
print(lst[index])

+ 5
- 0
test/偏函数/__init__.py View File

@@ -0,0 +1,5 @@
import getopt
import keyword

print(keyword.kwlist)
print(getopt.__doc__)

+ 50
- 0
test/偏函数/cmp_to_key.py View File

@@ -0,0 +1,50 @@
"""
python标准模块functools中的cmp_to_key可以将一个cmp函数变成一个key函数,从而支持自定义排序
python的列表提供了sort方法,下面是该方法的一个示例
"""
lst = [(9, 4), (2, 10), (4, 3), (3, 6)]
lst.sort(key=lambda item: item[0])
print(lst)
"""
sort方法的key参数需要设置一个函数,这个函数返回元素参与大小比较的值,这看起来没有问题,但如果想实现更加复杂的自定义排序,就不那么容易了。
目前的排序规则是根据元组里第一个元素的大小进行排序,我现在修改规则,如果元组里第一个元素是奇数,就用元组里第一个元素进行排序,
如果元组里第一个元素是偶数,则用这个元组里的第二个元组进行大小比较,面对这样的需求,列表的sort方法无法满足。
对于这种情形,可以使用functools.cmp_to_key来解决
"""
from functools import cmp_to_key
lst = [(9, 4), (2, 10), (4, 3), (3, 6)]
def cmp(x, y):
a = x[0] if x[0] % 2 == 1 else x[1]
b = y[0] if y[0] % 2 == 1 else y[1]
return 1 if a > b else -1 if a < b else 0

lst.sort(key=cmp_to_key(cmp))
print(lst)
# 仍然使用sort进行排序,我实现了一个cmp函数,该函数实现了需求中所提到的要求,该函数最终要返回两个元组比较的大小关系,其实cmp_to_key的实现非常简单

def cmp_to_key(mycmp):
"""Convert a cmp= function into a key= function"""
class K(object):
__slots__ = ['obj']
def __init__(self, obj):
self.obj = obj
def __lt__(self, other):
return mycmp(self.obj, other.obj) < 0
def __gt__(self, other):
return mycmp(self.obj, other.obj) > 0
def __eq__(self, other):
return mycmp(self.obj, other.obj) == 0
def __le__(self, other):
return mycmp(self.obj, other.obj) <= 0
def __ge__(self, other):
return mycmp(self.obj, other.obj) >= 0
__hash__ = None
return K
"""
它在内部定义了一个类K, 并使用我传入的cmp函数完成了比较关系运算符的重载,函数返回的是一个类,而sort函数的key需要的是一个函数,
看起来矛盾,但在python中,这样做完全可行,因为类和函数都是callable的,这里把类当成了函数来用。
在本篇第一段代码中
lst.sort(key=lambda item: item[0])
lambda表达式生成的匿名函数返回的是元组的第一个元素进行大小比较,而现在,cmp_to_key返回的是类K,参与比较的是K的对象,
由于K已经实现了比较关系运算符重载,且算法就是我刚刚实现的cmp函数,这样就最终实现了自定义排序。
"""

+ 31
- 0
test/偏函数/demo.py View File

@@ -0,0 +1,31 @@
"""
1. 偏函数
偏函数partial是functools 模块里提供的一个函数。和装饰器对比来理解,装饰器改变了一个函数的行为,
而偏函数不能改变一个函数的行为。偏函数只能根据已有的函数生成一个新的函数,这个新的函数完成已有函数相同的功能,
但是,这个新的函数的部分参数已被偏函数确定下来

2. 场景示例
2.1 常规实现
为了便于理解,我们构造一个使用场景,假设我们的程序要在dest目录下新建一些文件夹,那么常见的实现功能代码如下
import os
from os import mkdir
mkdir(os.path.join('./dest', 'dir1'))
mkdir(os.path.join('./dest', 'dir2'))
mkdir(os.path.join('./dest', 'dir3'))
功能很简单,代码很简洁,但是有个小小的不如意之处,每次都是在dest目录下新建文件夹,既然它这么固定,是不是可以不用传递dest参数呢?
2.2 偏函数实现
import os
from os import mkdir
from functools import partial

dest_join = partial(os.path.join, './dest')
mkdir(dest_join('dir1'))
mkdir(dest_join('dir2'))
mkdir(dest_join('dir3'))

dest_join是partial创建出来的一个新的函数,这个函数在执行时会调用os.path.join并将'./dest'作为参数传给join
偏函数将预先确定的参数冻结,起到了缓存的作用,在获得了剩余的参数后,连同之前冻结的确定参数一同传给最终的处理函数。
虽然看起来代码没有减少,但如果你实际使用就会发现,用了偏函数,免去了反复输入相同参数的麻烦,尤其当这些参数很多很难记忆时
"""



+ 39
- 0
test/偏函数/singledispatch.py View File

@@ -0,0 +1,39 @@
from functools import singledispatch

class Stu(object):
def __init__(self, name):
self.name = name

def wake_up(self):
print('起床')

class Police(object):
def __init__(self, name):
self.name = name

def wake_up(self):
print('起床')


@singledispatch
def wake_up(obj):
print('不处理')


@wake_up.register(Stu)
def wake_stu(obj):
print('今天周末休息,让孩子们再睡一会')


@wake_up.register(Police)
def wake_police(obj):
print('警察很辛苦,又要起床了')
obj.wake_up()


stu = Stu('小明')
police = Police('小明爸爸')

wake_up(stu)
wake_police(police)
wake_up('一个字符串')

+ 26
- 0
test/偏函数/wraps.py View File

@@ -0,0 +1,26 @@
import time
from functools import wraps


def cost(func):
@wraps(func)
def warpper(*args, **kwargs):
t1 = time.time()
res = func(*args, **kwargs)
t2 = time.time()
print(func.__name__ + "执行耗时" + str(t2-t1))
return res
return warpper

@cost
def test(sleep_time):
"""
测试装饰器
:param sleep_time:
:return:
"""
time.sleep(sleep_time)


print(test.__name__)
print(test.__doc__)

+ 0
- 0
test/内置函数/__init__.py View File


+ 11
- 0
test/内置函数/test.py View File

@@ -0,0 +1,11 @@



# key参数,表示使用指定的方法来比较大小,而不是使用原数据比较大小
x = (2, 3, 4, 5)
print(max(x))

print(max(x, key=lambda z: 1 / z))

############################### collections #################################


+ 21
- 0
test/序列化/test1.py View File

@@ -0,0 +1,21 @@
import sys

import msgpack

stu = {
'name': 'lili',
'age': 18,
'score': 100
}

msg_str = msgpack.packb(stu)
print(msg_str)
print(len(msg_str))
print(sys.platform)
print(sys.byteorder)
print(sys.modules)
print(sys.thread_info)
print(sys.implementation)
print(sys.hash_info)
print(sys.getwindowsversion())
print(sys.getrecursionlimit())

+ 0
- 0
test/异常/__init__.py View File


+ 6
- 0
test/异常/test.py View File

@@ -0,0 +1,6 @@
"""
1. try-except
2. try-except-except
3. try-except-else
4. try-except-finally
"""

+ 29
- 0
test/正则/demo.py View File

@@ -0,0 +1,29 @@
# -*- coding: UTF-8 -*-

import re
print(re.match('www', 'www.runoob.com').span()) # 在起始位置匹配
print(re.match('com', 'www.runoob.com')) # 不在起始位置匹配

line = "Cats are smarter than dogs";

matchObj = re.match(r'dogs', line, re.M|re.I)
if matchObj:
print("match --> matchObj.group() : ", matchObj.group())
else:
print("No match!!")

matchObj = re.search(r'dogs', line, re.M|re.I)
if matchObj:
print("search --> searchObj.group() : ", matchObj.group())
else:
print("No match!!")

phone = "2004-959-559 # 这是一个国外电话号码"

# 删除字符串中的 Python注释
num = re.sub(r'#.*$', "", phone)
print("电话号码是: ", num)

# 删除非数字(-)的字符串
num = re.sub(r'\D', "", phone)
print("电话号码是 : ", num)

+ 62
- 0
test/游戏/Food.py View File

@@ -0,0 +1,62 @@
import pygame

STEP = 44


class Food():
def __init__(self, x, y, surface):
self.x = x * STEP
self.y = y * STEP
self.surface = surface
self.image = pygame.image.load("food.png").convert()

def draw(self):
self.surface.blit(self.image, (self.x, self.y))

class Snake():
def __init__(self, x, y, surface):
self.x = [x*STEP]
self.y = [y*STEP] # 用两个列表来存储贪吃蛇每个节点的位置
self.length = 1 # 贪吃蛇的长度
self.direction = 0 # 0表示向右, 1表示向下, 2表示向左, 3表示向上
self.image = pygame.image.load("snake.png").convert() # 加载蛇
self.surface = surface
self.step = 44 # 运动步长
self.updateCount = 0 # 更新次数

# 虽然有这么多节点,但是有length来控制界面上画出多少蛇的节点
for i in range(1, 100):
self.x.append(-100)
self.y.append(-100)

def draw(self):
for i in range(self.length):
self.surface.blit(self.image, (self.x[i],self.y[i]))

def moveRight(self):
self.direction = 0

def moveLeft(self):
self.direction = 2

def moveUp(self):
self.direction = 3

def moveDown(self):
self.direction = 1

def update(self):
self.updateCount += 1
if self.updateCount > 2:
for i in range(self.length-1, 0, -1):
self.x[i] = self.x[i-1]
self.y[i] = self.y[i-1]
if self.direction == 0:
self.x[0] = self.x[0] + self.step # 向右
if self.direction == 1:
self.y[0] = self.y[0] + self.step # 向下
if self.direction == 2:
self.x[0] = self.x[0] - self.step # 向左
if self.direction == 3:
self.y[0] = self.y[0] - self.step # 向上
self.updateCount = 0

+ 93
- 0
test/游戏/SnakeGame.py View File

@@ -0,0 +1,93 @@
import random

from pygame.locals import *
import pygame
import time

from test.游戏.Food import Food, Snake, STEP


class SnakeGame():
def __init__(self):
self.width = 800
self.height = 600
self._running = False


def init(self):
pygame.init() #初始化所有导入的pygame模块
# 初始化一个准备显示的窗口或屏幕
self._display_surf = pygame.display.set_mode((self.width,self.height), pygame.HWSURFACE)
self.food = Food(5, 5, self._display_surf)
self.snake = Snake(1, 1, self._display_surf)
self._running = True

def run(self):
self.init()
while self._running:
pygame.event.pump() # 内部处理pygame事件处理程序
self.listen_keybord() # 监听键盘上下左右键
self.loop()
self.render()
time.sleep(0.05)

def listen_keybord(self):
keys = pygame.key.get_pressed()

if (keys[K_RIGHT]):
self.snake.moveRight()

if (keys[K_LEFT]):
self.snake.moveLeft()

if (keys[K_UP]):
self.snake.moveUp()

if (keys[K_DOWN]):
self.snake.moveDown()

if (keys[K_ESCAPE]):
self._running = False

def render(self):
self._display_surf.fill((0, 0, 0)) # 游戏界面填充为黑色
self.food.draw() # 画出食物
self.snake.draw() # 画出蛇
pygame.display.flip() # 刷新屏幕


def loop(self):
self.snake.update()
self.eat()
self.faild_check()

def faild_check(self):
# 检查是否吃到了自己
for i in range(2,self.snake.length):
if self.isCollision(self.snake.x[0], self.snake.y[0], self.snake.x[i], self.snake.y[i],40):
print('吃到自己了')
exit(0)

if self.snake.x[0] < 0 or self.snake.x[0] > self.width \
or self.snake.y[0] < 0 or self.snake.y[0] > self.height:
print('出边界了')
exit(0)

def eat(self):
if self.isCollision(self.food.x, self.food.y, self.snake.x[0], self.snake.y[0], 40):
self.food.x = random.randint(2, 9)*STEP
self.food.y = random.randint(2, 9)*STEP
self.snake.length += 1 # 蛇的长度加1



@staticmethod
def isCollision(x1, y1, x2, y2, bsize):
if x1 >= x2 and x1 <= x2 + bsize:
if y1 >= y2 and y1 <= y2 + bsize:
return True
return False

if __name__ == '__main__':
snake = SnakeGame()
snake.run()

+ 0
- 0
test/游戏/__init__.py View File


BIN
test/游戏/__pycache__/Food.cpython-38.pyc View File


BIN
test/游戏/__pycache__/__init__.cpython-38.pyc View File


BIN
test/游戏/food.png View File

Before After
Width: 37  |  Height: 35  |  Size: 749B

BIN
test/游戏/snake.png View File

Before After
Width: 39  |  Height: 38  |  Size: 734B

+ 0
- 0
test/算法/__init__.py View File


+ 20
- 0
test/算法/冒泡.py View File

@@ -0,0 +1,20 @@

def pop_sort(lst):
for i in range(len(lst)-1, 0, -1):
move_max(lst, i)


def move_max(lst, max_index):
for i in range(max_index):
if lst[i] > lst[i+1]:
lst[i], lst[i+1] = lst[i+1], lst[i]

if __name__ == '__main__':
lst = [4, 1, 7, 2, 3, 6]
# pop_sort(lst)
# print(lst)
for j in range(len(lst) - 1, 0, -1):
for i in j:
if lst[i] > lst[i+1]:
lst[i], lst[i+1] = lst[i+1], lst[i]


+ 21
- 0
test/算法/插入.py View File

@@ -0,0 +1,21 @@
def insert(lst, index):
if lst[index-1] < lst[index]:
return

tmp = lst[index]
tmp_index = index
while tmp_index > 0 and lst[tmp_index-1] > tmp:
lst[tmp_index] = lst[tmp_index-1]
tmp_index -= 1
lst[tmp_index] = tmp


def insert_sort(lst):
for i in range(1, len(lst)):
insert(lst, i)


if __name__ == '__main__':
lst = [1, 6, 2, 7, 5]
insert_sort(lst)
print(lst)

+ 21
- 0
test/算法/选择.py View File

@@ -0,0 +1,21 @@
"""
假设有一个序列,a[0],a[1],a[2]...a[n]现在,对它进行排序。我们先从0这个位置到n这个位置找出最小值,然后将这个最小值与a[0]交换,
然后呢,a[1]到a[n]就是我们接下来要排序的序列
我们可以从1这个位置到n这个位置找出最小值,然后将这个最小值与a[1]交换,之后,a[2]到a[n]就是我们接下来要排序的序列
每一次,我们都从序列中找出一个最小值,然后把它与序列的第一个元素交换位置,这样下去,待排序的元素就会越来越少,直到最后一个
"""


def select_sort(lst):
for i in range(len(lst)):
min = i
for j in range(min, len(lst)):
# 寻找min 到len(lst)-1 这个范围内的最小值
if lst[min] > lst[j]:
min = j
lst[i], lst[min] = lst[min], lst[i]


lst = [2, 6, 1, 8, 2, 4, 9]
select_sort(lst)
print(lst)

+ 29
- 0
test/类型标注/test1.py View File

@@ -0,0 +1,29 @@
from typing import TypeVar, Generic, List


T = TypeVar('T')


class Stack(Generic[T]):
def __init__(self):
self.data: List[T] = []

def push(self, item: T):
self.data.append(item)

def pop(self) -> T:
return self.data.pop(-1)

def top(self) -> T:
return self.data[-1]

def size(self) -> int:
return len(self.data)

def is_empty(self) -> bool:
return len(self.data) == 0

stack = Stack[int]()
stack.push('3')
stack.push('5')
print(stack.pop())

+ 1
- 1
test/设计模式/简单工厂模式/demo1.py View File

@@ -41,4 +41,4 @@ fruit1.make_juice() # 制作苹果汁


fruit2 = OrangeFactory().create_fruit()
fruit2.make_juice()
fruit2.make_juice()

+ 0
- 0
test/语法/__init__.py View File


+ 0
- 0
test/语法/datetime/__init__.py View File


+ 106
- 0
test/语法/datetime/test.py View File

@@ -0,0 +1,106 @@
import datetime
import time

# # 今天的日期
# print("今天的日期是:", datetime.date.today())
#
# print("使用时间戳创建日期", datetime.date.fromtimestamp(1234567896))
#
# print("使用公历序数创建的日期:", datetime.date.fromordinal(1))
#
# today = datetime.date(year=2020,month=8,day=31) # 使用参数创建日期
#
# print('date对象的年份:', today.year)
#
# print('date对象的月份:', today.month)
#
# print('date对象的日:', today.day)
#
# print("date对象的struct_time结构为:",today.timetuple())
#
# print("返回当前公历日期的序数:",today.toordinal()) # 与fromordinal函数作用相反
#
# print("当前日期为星期(其中:周一对应0):{}".format(today.weekday()))
#
# print("当前日期为星期(其中:周一对应1):{}".format(today.isoweekday()))
#
# print("当前日期的年份、第几周、周几(其中返回为元组):",today.isocalendar())
#
# print("以ISO 8601格式‘YYYY-MM-DD’返回date的字符串形式:",today.isoformat())
#
# print("返回一个表示日期的字符串(其格式如:Mon Aug 31 00:00:00 2020):",today.ctime())
#
# print("指定格式为:",today.strftime("%Y/%m/%d"))
#
# print("替换后的日期为:",today.replace(2019,9,29))
#
# create_time = datetime.time(hour=11,minute=18,second=31) # 使用参数创建日期
#
# print('create_time对象的小时为:', create_time.hour)
#
# print('create_time对象的分钟为:', create_time.minute)
#
# print('create_time对象的秒数为:', create_time.second)
#
# print("返回create_time的字符串形式:",create_time.isoformat())
#
# print("指定格式为:",create_time.strftime("%H/%M/%S"))
#
# print("替换后的时间为:",create_time.replace(20,9,29))
#
# print("现在的时间是:",datetime.datetime.today())
#
# print("返回现在的时间是:",datetime.datetime.now())
#
# print("当前UTC日期和时间是:",datetime.datetime.utcnow())
#
# print("对应时间戳的日期和时间是:",datetime.datetime.fromtimestamp(1234567896))
#
# print("对应UTC时间戳的日期和时间是:",datetime.datetime.utcfromtimestamp(1234567896))
#
# print("公历序列对应的日期和时间是:",datetime.datetime.fromordinal(1))
#
# print("日期和时间的合体为:",datetime.datetime.combine(datetime.date(2020, 8, 31), datetime.time(12, 12, 12)))
#
# now = datetime.datetime(2020,8,31,12,10,10)
#
# print("年为:",now.year)
#
# print("月为:",now.month)
#
# print("日为:",now.day)
#
# print("小时为:",now.hour)
#
# print("分钟为:",now.minute)
#
# print("秒数为:",now.second)
#
# print('当前日期为:', now.date() )
#
# print('当前时间:', now.time() )
#
# print("返回struct_time为",now.timetuple()) # 和date一样
#
# print("返回UTC的struct_time为",now.utctimetuple())
#
# print("返回的公历序列数为:",now.toordinal()) # 和date一样
#
# print("返回标准日期格式为:",now.isoformat()) # 和date一样
#
# print("返回的周几(1表示周一):",now.isoweekday()) # 和date一样
#
# print("返回的周几(0表示周一):",now.weekday()) # 和date一样
#
# print("now.isocalendar():", now.isocalendar()) # 和date一样
#
# print("now.ctime():",now.ctime()) # 和date一样
#
# print("格式化时间为:",now.strftime('%Y/%m/%d %H:%M:%S')) # 把日期按照format指定的格式进行格式化
#
# print(datetime.datetime.strptime("2020/12/29 8:8:00",'%Y/%m/%d %H:%M:%S'))

current_time = 1577761708
date_time = datetime.datetime.fromtimestamp(current_time)
print(date_time)
print(time.localtime())

+ 0
- 0
test/语法/for/__init__.py View File


+ 43
- 0
test/语法/for/demo.py View File

@@ -0,0 +1,43 @@

magicians = ['alice', 'david', 'carolina']
for magician in magicians:
print(magician)

print(0b1101010)

value = int('1101010', 2)
print(value) # 106

value = int('125', 8)
print(value) # 85

value = int('3f2a1', 16)
print(value) # 258721

print(bin(106)) # 0b1101010 十进制转二进制
print(oct(85)) # 0o125 十进制转八进制
print(hex(258721)) # 0x3f2a1 十进制转十六进制

text = '1aa2'
print(text.split('a'))

# 1. 将字符串 "abcd" 转成大写
print("abcd".upper())
# 2. 计算字符串 "cd" 在 字符串 "abcd"中出现的位置
print("abcd".index('cd'))
print("abcd".find('cd'))
# 3. 字符串 "a,b,c,d" ,请用逗号分割字符串,分割后的结果是什么类型的?
print("a,b,c,d".split(','))
# 4. "{name}喜欢{fruit}".format(name="李雷") 执行会出错,请修改代码让其正确执行
print("{name}喜欢{fruit}".format(name="李雷", fruit='水果'))
# 5. string = "Python is good", 请将字符串里的Python替换成 python,并输出替换后的结果
print("Python is good".replace("Python", "python"))
# 6. 有一个字符串 string = "python修炼第一期.html",请写程序从这个字符串里获得.html前面的部分,要用尽可能多的方式来做这个事情
print("python修炼第一期.html".split('.')[0])
# 7. 如何获取字符串的长度?
# 8. "this is a book",请将字符串里的book替换成apple
# 9. "this is a book", 请用程序判断该字符串是否以this开头
# 10. "this is a book", 请用程序判断该字符串是否以apple结尾
# 11. "This IS a book", 请将字符串里的大写字符转成小写字符
# 12. "This IS a book", 请将字符串里的小写字符,转成大写字符
# 13. "this is a book\n", 字符串的末尾有一个回车符,请将其删除

+ 0
- 0
test/语法/list/__init__.py View File


+ 34
- 0
test/语法/list/demo.py View File

@@ -0,0 +1,34 @@
bicycles = ['trek', 'cannondale', 'redline', 'specialized']
print(bicycles)
print(bicycles[0])
print(bicycles[0].title())
print(bicycles[-1])

motorcycles = ['honda', 'yamaha', 'suzuki']
print(motorcycles)
motorcycles[0] = 'ducati'
print(motorcycles)
motorcycles.append('ducati')
print(motorcycles)
motorcycles.insert(0, 'ducati')
print(motorcycles)
del motorcycles[0]
print(motorcycles)
popped_motorcycle = motorcycles.pop()
print(motorcycles)
print(popped_motorcycle)

# 使用方法 sort()对列表进行永久性排序
cars = ['bmw', 'audi', 'toyota', 'subaru']
cars.sort()
print(cars)
cars.sort(reverse=True)
print(cars)

# 使用函数 sorted()对列表进行临时排序
cars = ['bmw', 'audi', 'toyota', 'subaru']
print(cars)
print(sorted(cars))
print(sorted(cars, reverse=True))
print(cars.reverse())
print(len(cars))

+ 0
- 0
test/语法/statistics_test/__init__.py View File


+ 16
- 0
test/语法/statistics_test/test.py View File

@@ -0,0 +1,16 @@
import statistics

lst = [1, 4, 5, 7, 1, 3, 6, 9, 19]

print(statistics.mean(lst)) # 算数平均值
print(statistics.harmonic_mean(lst)) # 调和平均值
print(statistics.median(lst)) # 中位数
print(statistics.median_low(lst)) # 数据的第一个中位数(总数为偶数时有两个中位数)
print(statistics.median_high(lst)) # 数据的第二个中位数
print(statistics.median_grouped(lst)) # 分组数据的中位数的均值
print(statistics.mode(lst)) # 离散数据的模式, 数据中最常见的值

print(statistics.pstdev(lst)) # 数据总体的标准差
print(statistics.pvariance(lst)) # 数据总体的方差
print(statistics.stdev(lst)) # 数据样本的标准差
print(statistics.variance(lst)) # 数据样本的方差

+ 0
- 0
test/语法/time/__init__.py View File


+ 42
- 0
test/语法/time/test.py View File

@@ -0,0 +1,42 @@
import time

# 获取当前时间戳 1685344329.938672
print(time.time())

# 获取当前时间,表示为计算机可处理的时间格式
print(time.gmtime())

# 时间格式化:将时间以合理的方式展示出来
print(time.strftime("%Y-%m-%d %H:%M:%S", time.gmtime()))
print(time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(time.time())))
print(time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()))
#
print(time.strptime("2023-05-29 07:21:07", "%Y-%m-%d %H:%M:%S"))

# 返回一个CPU级别的精确时间计数值, 单位为秒, 由于这个计算值七点不确定,连续调用差值才有意义
print(time.perf_counter())

# 获取当前时间
print(time.localtime(time.time()))
print(time.localtime())

# 接受时间元组并返回一个可读的形式为"Tue Dec 11 18:07:14 2008"(2008年12月11日 周二18时07分14秒)的24个字符的字符串。
print(time.asctime(time.localtime(time.time())))
print(time.asctime(time.localtime()))
# 获取当前时间并以易读方式表示,返回字符串
print(time.ctime()) # Mon May 29 15:16:00 2023

# 返回格林威治西部的夏令时地区的偏移秒数。如果该地区在格林威治东部会返回负值(如西欧,包括英国)。对夏令时启用地区才能使用。
print(time.altzone)

#
start = time.perf_counter()
start1 = time.process_time()
time.sleep(1)
end = time.perf_counter()
end1 = time.process_time()
print(end - start)
print(end1 - start1)

# 接受时间对象并返回时间戳(1970纪元后经过的浮点秒数)
print(time.mktime(time.localtime()))

+ 27
- 0
test/语法/全局变量.py View File

@@ -0,0 +1,27 @@

def get_mathematical_score():
return 90


def get_english_score():
return 95


def get_history_score():
return 98


def get_score_by_course(course):
"""
根据课程获取考试分数
:param course:
:return:
"""
global_dict = globals()
print(global_dict)
func_name = 'get_{course}_score'.format(course=course)
func = global_dict.get(func_name)
return func()


print(get_score_by_course('history'))

+ 51
- 0
test/语法/全局变量1.py View File

@@ -0,0 +1,51 @@
def func_dispatch(func):
registry = {}

def dispatch(key_word):
return registry.get(key_word, registry[object])

def register(key_word, func=None):
if func is None:
return lambda f: register(key_word, f)

registry[key_word] = func
return func

def wrapper(*args, **kw):
return dispatch(args[0])(*args, **kw)

registry[object] = func
wrapper.register = register
return wrapper


@func_dispatch
def score_dispath(course):
return 0


@score_dispath.register('mathematical')
def get_mathematical_score(course):
return 90


@score_dispath.register('english')
def get_english_score(course):
return 95


@score_dispath.register('history')
def get_history_score(course):
return 98


def get_score_by_course(course):
"""
根据课程获取考试分数
:param course:
:return:
"""
return score_dispath(course)


print(get_score_by_course('mathematical'))

+ 39
- 0
test/语法/回调.py View File

@@ -0,0 +1,39 @@
class TestClass(object):
def __init__(self):
self.fun = 0

def decorator(self, fun):
#通过fun变量实现对传入函数的回调
self.fun = fun
#仅注册回调函数,将原函数返回,不执行原函数工鞥呢,不改变原函数功能
return fun

def decorator1(self, type):
def wrapper(func):
if type == 'A':
self.fun_A = func
if type == 'B':
self.fun_B = func
return func
return wrapper

test = TestClass()

#将decorator_test函数传入test的decorator函数,并执行decorator函数
@test.decorator
def decorator_test():
print('this is decorator_test')

@test.decorator1('A')
def decorator_test():
print('this is decorator_test A')

@test.decorator1('B')
def decorator_test():
print('this is decorator_test B')

#通过test的fun变量回调decorator_test函数
test.fun();

test.fun_A ();
test.fun_B ();

+ 0
- 0
test/语法/装饰器/__init__.py View File


+ 0
- 0
test/读写/__init__.py View File


+ 20
- 0
test/读写/csv_test.py View File

@@ -0,0 +1,20 @@

import csv

import numpy as np

with open("data.csv") as f:
csv_reader = csv.reader(f)
for row in csv_reader:
print(row)

import pandas as pd
df = pd.read_csv("data.csv", encoding="utf-8")
print(df)
df_array = np.array(df) # 将pandas读取的数据转化为array
df_list = df_array.tolist() # 将数组转化为list
print(df_list)
x = df[['name', 'age']]
print(x)
y = df[['name']]
print(y)

+ 4
- 0
test/读写/data.csv View File

@@ -0,0 +1,4 @@
name,age
1,1
2,2
3,3

+ 29
- 0
test/读写/demo.py View File

@@ -0,0 +1,29 @@
"""
模式 描述
r 以只读的形式打开文件,文件的指针在开头
r+ 读写,文件指针在开头
rb 以二进制的形式,只读文件指针在开头
w 只写,文件不存在,则创建新的,存在则覆盖,指针在开头
w+ 读写,文件不存在,则创建新的,存在则覆盖,指针在开头
wb 只写,以二进制的形式
a 追加模式,文件指针在结尾
a+ 读写,不存在则创建,存在直接追加
ab 以二进制形式追加

1. close(): 关闭文件---非常重要
2. read([count]): 读取文件中的内容 count:字节数量
3. readlines(): 读取所有内容,打包成列表
4. readline(): 读取一行数据,追加读取,读取过的不能再次读取
5. seek(offset,[from]): 修改指针的位置:从from位置移动了offset个字节,
from:0则表示从起始位置,1则表示从当前位置开始,2则表示从末尾开始
offset:要移动的字节数
6. write(): 向文件中写入内容
"""

# 写文件
# with open("hello.txt", 'w') as f:
# f.write("hello world")

# 读文件
with open("hello.txt", 'r') as f:
print(f.read())

+ 1
- 0
test/读写/hello.txt View File

@@ -0,0 +1 @@
hello world

+ 0
- 1
util/AliyunSdk.py View File

@@ -12,7 +12,6 @@ import json
from aliyunsdkcore.client import AcsClient
from aliyunsdkvod.request.v20170321 import GetPlayInfoRequest

from util import LogUtils
from vodsdk.AliyunVodUploader import AliyunVodUploader
from vodsdk.UploadVideoRequest import UploadVideoRequest


+ 11
- 3
util/Cv2Utils.py View File

@@ -89,7 +89,7 @@ class Cv2Util():
fps = video_stream.get('r_frame_rate')
# duration = video_stream.get('duration')
# bit_rate = video_stream.get('bit_rate')
if width is not None and height is not None:
if width is not None and int(width) != 0 and height is not None and int(height) != 0:
self.width = int(width)
self.height = int(height)
self.wh = self.width * self.height * 3
@@ -103,7 +103,13 @@ class Cv2Util():
self.all_frames = int(nb_frames)
up, down = str(fps).split('/')
self.fps = int(eval(up) / eval(down))
# if duration:
if self.fps > 30:
self.__logger.info("获取视频FPS大于30帧, FPS:{}, requestId:{}", self.fps, self.requestId)
self.fps = 30
if self.fps < 25:
self.__logger.info("获取视频FPS小于25帧, FPS:{}, requestId:{}", self.fps, self.requestId)
self.fps = 25
# if duration:
# self.duration = float(video_stream['duration'])
# self.bit_rate = int(bit_rate) / 1000
self.__logger.info("视频信息, width:{}|height:{}|fps:{}|all_frames:{}|bit_rate:{}, requestId:{}",
@@ -187,6 +193,7 @@ class Cv2Util():
command.extend(['-i', self.pullUrl,
'-f', 'rawvideo',
'-pix_fmt', 'bgr24',
'-r', '30',
'-an',
'-'])
self.pull_p = sp.Popen(command, stdout=sp.PIPE)
@@ -256,6 +263,7 @@ class Cv2Util():
'-i', self.pullUrl,
'-f', 'rawvideo',
'-pix_fmt', 'bgr24',
'-r', '30',
'-an',
'-'])
self.pull_p = sp.Popen(command, stdout=sp.PIPE)
@@ -409,7 +417,7 @@ class Cv2Util():
'-s', "{}x{}".format(self.w * 2, self.h),
'-r', str(self.fps),
'-i', '-', # 指定输入文件
'-g', str(self.fps),
'-g', str(30),
'-maxrate', '6000k',
# '-profile:v', 'high',
'-b:v', '5000k',

BIN
vodsdk/__pycache__/AliyunVodUploader.cpython-38.pyc View File


BIN
vodsdk/__pycache__/AliyunVodUtils.cpython-38.pyc View File


Loading…
Cancel
Save