функции для сохранения, изменения и создания файлов для бота

This commit is contained in:
mega_krevetka committed 2026-04-02 17:37:48 +03:00
1 parent edf0be7b4c
commit f25d30cb25
2 files changed
+48 -13

No files matched your search

+30 -13
View File
@@ -4,7 +4,10 @@
<option name="autoReloadType" value="SELECTIVE" />
</component>
<component name="ChangeListManager">
<list default="true" id="aaf4cea1-996f-4616-a7e8-5aebcf6aea3e" name="Changes" comment="test" />
<list default="true" id="aaf4cea1-996f-4616-a7e8-5aebcf6aea3e" name="Changes" comment="функции для сохранения, изменения и создания файлов для бота">
<change afterPath="$PROJECT_DIR$/pyLessons/filemanager.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
@@ -33,21 +36,25 @@
&quot;associatedIndex&quot;: 6
}</component>
<component name="ProjectId" id="3BhbFCTFV4R0VVKYpM8sZkvMBml" />
<component name="ProjectLevelVcsManager">
<ConfirmationsSetting value="2" id="Add" />
</component>
<component name="ProjectViewState">
<option name="hideEmptyMiddlePackages" value="true" />
<option name="showLibraryContents" value="true" />
</component>
<component name="PropertiesComponent"><![CDATA[{
"keyToString": {
"ASKED_SHARE_PROJECT_CONFIGURATION_FILES": "true",
"ModuleVcsDetector.initialDetectionPerformed": "true",
"RunOnceActivity.ShowReadmeOnStart": "true",
"RunOnceActivity.git.unshallow": "true",
"git-widget-placeholder": "main",
"last_opened_file_path": "C:/Users/Dream/python",
"settings.editor.selected.configurable": "com.jetbrains.python.configuration.PyActiveSdkModuleConfigurable"
<component name="PropertiesComponent">{
&quot;keyToString&quot;: {
&quot;ASKED_SHARE_PROJECT_CONFIGURATION_FILES&quot;: &quot;true&quot;,
&quot;ModuleVcsDetector.initialDetectionPerformed&quot;: &quot;true&quot;,
&quot;RunOnceActivity.ShowReadmeOnStart&quot;: &quot;true&quot;,
&quot;RunOnceActivity.git.unshallow&quot;: &quot;true&quot;,
&quot;git-widget-placeholder&quot;: &quot;main&quot;,
&quot;ignore.virus.scanning.warn.message&quot;: &quot;true&quot;,
&quot;last_opened_file_path&quot;: &quot;C:/Users/Dream/python&quot;,
&quot;settings.editor.selected.configurable&quot;: &quot;com.jetbrains.python.configuration.PyActiveSdkModuleConfigurable&quot;
}
}]]></component>
}</component>
<component name="SharedIndexes">
<attachedChunks>
<set>
@@ -103,7 +110,15 @@
<option name="project" value="LOCAL" />
<updated>1774946246052</updated>
</task>
<option name="localTasksCounter" value="6" />
<task id="LOCAL-00006" summary="test2">
<option name="closed" value="true" />
<created>1775069680989</created>
<option name="number" value="00006" />
<option name="presentableId" value="LOCAL-00006" />
<option name="project" value="LOCAL" />
<updated>1775069680989</updated>
</task>
<option name="localTasksCounter" value="7" />
<servers />
</component>
<component name="UpdateCopyrightCheckinHandler">
@@ -114,7 +129,9 @@
<option name="CHECK_CODE_CLEANUP_BEFORE_PROJECT_COMMIT" value="true" />
<MESSAGE value="исправленные import-ы" />
<MESSAGE value="test" />
<option name="LAST_COMMIT_MESSAGE" value="test" />
<MESSAGE value="test2" />
<MESSAGE value="функции для сохранения, изменения и создания файлов для бота" />
<option name="LAST_COMMIT_MESSAGE" value="функции для сохранения, изменения и создания файлов для бота" />
<option name="OPTIMIZE_IMPORTS_BEFORE_PROJECT_COMMIT" value="true" />
<option name="REFORMAT_BEFORE_PROJECT_COMMIT" value="true" />
<option name="REARRANGE_BEFORE_PROJECT_COMMIT" value="true" />
+18
View File
@@ -0,0 +1,18 @@
def save_to_file(name, data):
# начало
with open(name, "w", encoding="utf-8") as file:
file.write(data)
# конец
def load_from_file(name):
data = ""
with open(name, "r", encoding="utf-8") as file:
data = file.read()
return data
def create_file(name):
with open(name, "x", encoding="utf-8") as file:
file.write("")