{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "e2aa535c",
   "metadata": {},
   "source": [
    "# f字符串\n",
    "一种更方便的格式化字符串的方法\n",
    "更多用法参考[f字符串](https://www.freecodecamp.org/news/python-f-strings-tutorial-how-to-use-f-strings-for-string-formatting/)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "9c65920f",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "this is hello world!\n"
     ]
    }
   ],
   "source": [
    "string = \"hello world!\"\n",
    "print (f\"this is {string}\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "d8645e44",
   "metadata": {},
   "source": [
    "# shape函数\n",
    "获得矩阵维度"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "4614c2b5",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "a的维度为(3, 3)\n",
      "b的长度为4\n",
      "b的长度为(4,)\n",
      "a的行数为3\n"
     ]
    }
   ],
   "source": [
    "import numpy as np\n",
    "a = np.eye(3)\n",
    "b = np.array([1, 2, 3, 4])\n",
    "print(f\"a的维度为{a.shape}\")\n",
    "print(f\"b的长度为{len(b)}\")\n",
    "print(f\"b的长度为{b.shape}\")\n",
    "m = a.shape[0]\n",
    "print(f\"a的行数为{m}\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "d0192747",
   "metadata": {},
   "source": [
    "# 格式化输出\n",
    "[格式化输出](https://www.ddbji.com/py/jichu/191.html)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.10"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {
    "height": "calc(100% - 180px)",
    "left": "10px",
    "top": "150px",
    "width": "165px"
   },
   "toc_section_display": true,
   "toc_window_display": true
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
