Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 6 of 6 for txt (0.13 sec)

  1. docs/em/docs/advanced/events.md

    👈 🗜 🔢 🔘 🕳 🤙 "**🔁 🔑 👨‍💼**".
    
    ```Python hl_lines="1  13"
    {!../../../docs_src/events/tutorial003.py!}
    ```
    
    **🔑 👨‍💼** 🐍 🕳 👈 👆 💪 ⚙️ `with` 📄, 🖼, `open()` 💪 ⚙️ 🔑 👨‍💼:
    
    ```Python
    with open("file.txt") as file:
        file.read()
    ```
    
    ⏮️ ⏬ 🐍, 📤 **🔁 🔑 👨‍💼**. 👆 🔜 ⚙️ ⚫️ ⏮️ `async with`:
    
    ```Python
    async with lifespan(app):
        await do_stuff()
    ```
    
    Plain Text
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Thu Apr 18 19:53:19 GMT 2024
    - 6.2K bytes
    - Viewed (0)
  2. docs/de/docs/advanced/events.md

    {!../../../docs_src/events/tutorial003.py!}
    ```
    
    Ein **Kontextmanager** in Python ist etwas, das Sie in einer `with`-Anweisung verwenden können, zum Beispiel kann `open()` als Kontextmanager verwendet werden:
    
    ```Python
    with open("file.txt") as file:
        file.read()
    ```
    
    In neueren Versionen von Python gibt es auch einen **asynchronen Kontextmanager**. Sie würden ihn mit `async with` verwenden:
    
    ```Python
    async with lifespan(app):
        await do_stuff()
    Plain Text
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Sat Mar 30 20:30:59 GMT 2024
    - 9.1K bytes
    - Viewed (0)
  3. docs/pt/docs/advanced/events.md

    {!../../../docs_src/events/tutorial003.py!}
    ```
    
    Um **gerenciador de contexto** em Python é algo que você pode usar em uma declaração `with`, por exemplo, `open()` pode ser usado como um gerenciador de contexto:
    
    ```Python
    with open("file.txt") as file:
        file.read()
    ```
    
    Nas versões mais recentes de Python, há também um **gerenciador de contexto assíncrono**. Você o usaria com `async with`:
    
    ```Python
    async with lifespan(app):
        await do_stuff()
    Plain Text
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Thu Apr 18 19:53:19 GMT 2024
    - 8.6K bytes
    - Viewed (0)
  4. docs/zh/docs/advanced/events.md

    只有所有 `startup` 事件处理器运行完毕,**FastAPI** 应用才开始接收请求。
    
    ## `shutdown` 事件
    
    使用 `shutdown` 事件声明 `app` 关闭时运行的函数:
    
    ```Python hl_lines="6"
    {!../../../docs_src/events/tutorial002.py!}
    ```
    
    此处,`shutdown` 事件处理器函数在 `log.txt` 中写入一行文本 `Application shutdown`。
    
    !!! info "说明"
    
        `open()` 函数中,`mode="a"` 指的是**追加**。因此这行文本会添加在文件已有内容之后,不会覆盖之前的内容。
    
    !!! tip "提示"
    
        注意,本例使用 Python `open()` 标准函数与文件交互。
    
        这个函数执行 I/O(输入/输出)操作,需要等待内容写进磁盘。
    Plain Text
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Thu Apr 18 19:53:19 GMT 2024
    - 1.7K bytes
    - Viewed (0)
  5. docs/en/docs/advanced/events.md

    {!../../../docs_src/events/tutorial003.py!}
    ```
    
    A **context manager** in Python is something that you can use in a `with` statement, for example, `open()` can be used as a context manager:
    
    ```Python
    with open("file.txt") as file:
        file.read()
    ```
    
    In recent versions of Python, there's also an **async context manager**. You would use it with `async with`:
    
    ```Python
    async with lifespan(app):
        await do_stuff()
    ```
    
    Plain Text
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Thu Apr 18 19:53:19 GMT 2024
    - 7.8K bytes
    - Viewed (0)
  6. docs/ko/docs/advanced/events.md

    응용 프로그램이 종료될 때 실행하려는 함수를 추가하려면 `"shutdown"` 이벤트로 선언합니다:
    
    ```Python hl_lines="6"
    {!../../../docs_src/events/tutorial002.py!}
    ```
    
    이 예제에서 `shutdown` 이벤트 핸들러 함수는 `"Application shutdown"`이라는 텍스트가 적힌 `log.txt` 파일을 추가할 것입니다.
    
    !!! info "정보"
        `open()` 함수에서 `mode="a"`는 "추가"를 의미합니다. 따라서 이미 존재하는 파일의 내용을 덮어쓰지 않고 새로운 줄을 추가합니다.
    
    !!! tip "팁"
        이 예제에서는 파일과 상호작용 하기 위해 파이썬 표준 함수인 `open()`을 사용하고 있습니다.
    
    Plain Text
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Tue Apr 02 22:35:55 GMT 2024
    - 2.2K bytes
    - Viewed (0)
Back to top