跳至主要內容
Python

Python


基本语法

Hello World

#!/usr/bin/env python

# -*- encoding: utf-8 -*-

def print_hi(name: str, say: str = 'I am python'):
    hello: str = 'Hello'
    print(f'{hello}, {name}! \n{say}')


if __name__ == '__main__':
    print_hi('World')

    
[root@loacl ~]python3 run.py
Hello, World! 
I am python

Section9lab...大约 3 分钟Languagepython
FastAPI

FastAPI


start

uvicorn main:app --reload

hello world

from fastapi import FastAPI
import uvicorn

app = FastAPI()

# http://127.0.0.1:8000/
@app.get("/")
async def root():
    return {"message": "Hello World"}

if __name__ == '__main__':
    uvicorn.run(app='main:app', reload=True)

Section9lab...大约 2 分钟Toolspython