\n\n

      Hello from PyScript!\n\n\n\nname = \"PyScript\"\n\nprint(f\"Hello, {name}! You are running Python in the browser.\")\n\n\n\n\n\n\n\n\n\n

      Step 3: Open the HTML file in a Browser.\n\n\n\n

      By default, there will be 3 files:\n\n\n\n

      main.py: Your Python code.

      Index.html: The main web page that includes PyScript.

      pyscript.toml: A configuration file listing any extra Python packages you
      want to use.\n\n\n\n

      Update the code files with the appropriate codes and start experimenting:\n\n\n\n

      \"PyScript:\n\n\n

      You can try PyScript Playground at PyScript examples to test code snippets directly in your browser.\n\n\n\n

      \"PyScript:\n\n\n

      Hands-on with PyScript\n\n\n\n

      Now that you are familiar with how the PyScript interface works, let us perform some hands-on with it.\n\n\n\n

      We will build a two-player tic-tac-toe game.\n\n\n\n

      Step 1: Update main.py?\n\n\n\n

      Add the main.py file with the TicTacToe class, which contains the game logic, user interactions, and UI updates. It will use PyWeb to connect Python with HTML, making the game fully interactive within the browser.\n\n\n\n

      Code:\n\n\n\n

      from pyweb import pydom\n\nclass TicTacToe:\n\ndef __init__(self):\n\nself.board = pydom[\"table#board\"]\n\nself.status = pydom[\"h2#status\"]\n\nself.console = pydom[\"script#console\"][0]\n\nself.init_cells()\n\nself.init_winning_combos()\n\nself.new_game(...)\n\ndef set_status(self, text):\n\nself.status.html = text\n\ndef init_cells(self):\n\nself.cells = []\n\nfor i in (0, 1, 2):\n\nrow = []\n\nfor j in (0, 1, 2):\n\ncell = pydom[f\"div#cell{i}{j}\"][0]\n\nassert cell\n\nrow.append(cell)\n\nself.cells.append(row)\n\ndef init_winning_combos(self):\n\nself.winning_combos = []\n\n# winning columns\n\nfor i in (0, 1, 2):\n\ncombo = []\n\nfor j in (0, 1, 2):\n\ncombo.append((i, j))\n\nself.winning_combos.append(combo)\n\n# winning rows\n\nfor j in (0, 1, 2):\n\ncombo = []\n\nfor i in (0, 1, 2):\n\ncombo.append((i, j))\n\nself.winning_combos.append(combo)\n\n# winning diagonals\n\nself.winning_combos.append([(0, 0), (1, 1), (2, 2)])\n\nself.winning_combos.append([(0, 2), (1, 1), (2, 0)])\n\ndef new_game(self, event):\n\nself.clear_terminal()\n\nprint('=================')\n\nprint('NEW GAME STARTING')\n\nprint()\n\nfor i in (0, 1, 2):\n\nfor j in (0, 1, 2):\n\nself.set_cell(i, j, \"\")\n\nself.current_player = \"x\"\n\nexperimentingself.set_status(f'{self.current_player} playing...')\n\ndef next_turn(self):\n\nwinner = self.check_winner()\n\nif winner == \"tie\":\n\nself.set_status(\"It's a tie!\")\n\nself.current_player = \"\" # i.e., game ended\n\nreturn\n\nelif winner is not None:\n\nself.set_status(f'{winner} wins')\n\nself.current_player = \"\" # i.e., game ended\n\nreturn\n\nif self.current_player == \"x\":\n\nself.current_player = \"o\"\n\nelse:\n\nself.current_player = \"x\"\n\nself.set_status(f'{self.current_player} playing...')\n\ndef check_winner(self):\n\n\"\"\"\n\nCheck whether the game as any winner.\n\nReturn \"x\", \"o\", \"tie\" or None. None means that the game is still playing.\n\n\"\"\"\n\n# check whether we have a winner\n\nfor combo in self.winning_combos:\n\nwinner = self.get_winner(combo)\n\nif winner:\n\n# highlight the winning cells\n\nfor i, j in combo:\n\nself.cells[i][j].add_class(\"win\")\n\nreturn winner\n\n# check whether it's a tie\n\nfor i in (0, 1, 2):\n\nfor j in (0, 1, 2):\n\nif self.get_cell(i, j) == \"\":\n\n# there is at least an empty cell, it's not a tie\n\nreturn None # game still playing\n\nreturn \"tie\"\n\ndef get_winner(self, combo):\n\n\"\"\"\n\nIf all the cells at the given points have the same value, return it.\n\nElse return \"\".\n\nEach point is a tuple of (i, j) coordinates.\n\nExample:\n\nself.get_winner([(0, 0), (1, 1), (2, 2)])\n\n\"\"\"\n\nassert len(combo) == 3\n\nvalues = [self.get_cell(i, j) for i, j in combo]\n\nif values[0] == values[1] == values[2] and values[0] != \"\":\n\nreturn values[0]\n\nreturn \"\"\n\ndef set_cell(self, i, j, value):\n\nassert value in (\"\", \"x\", \"o\")\n\ncell = self.cells[i][j]\n\ncell.html = value\n\nif \"x\" in cell.classes:\n\ncell.remove_class(\"x\")\n\nif \"o\" in cell.classes:\n\ncell.remove_class(\"o\")\n\nif \"win\" in cell.classes:\n\ncell.remove_class(\"win\")\n\nif value != \"\":\n\ncell.add_class(value)\n\ndef get_cell(self, i, j):\n\ncell = self.cells[i][j]\n\nvalue = cell.html\n\nassert value in (\"\", \"x\", \"o\")\n\nreturn value\n\ndef click(self, event):\n\ni = int(event.target.getAttribute('data-x'))\n\nj = int(event.target.getAttribute('data-y'))\n\nprint(f'Cell {i}, {j} clicked: ', end='')\n\nif self.current_player == \"\":\n\nprint('game ended, nothing to do')\n\nreturn\n\n#\n\nvalue = self.get_cell(i, j)\n\nif value == \"\":\n\nprint('cell empty, setting it')\n\nself.set_cell(i, j, self.current_player)\n\nself.next_turn()\n\nelse:\n\nprint(f'cell already full, cannot set it')\n\ndef clear_terminal(self):\n\nself.console._js.terminal.clear()\n\ndef toggle_terminal(self, event):\n\nhidden = self.console.parent._js.getAttribute(\"hidden\")\n\nif hidden:\n\nself.console.parent._js.removeAttribute(\"hidden\")\n\nelse:\n\nself.console.parent._js.setAttribute(\"hidden\", \"hidden\")\n\nGAME = TicTacToe()\n\n\n\n

      Step 2: Create a CSS file\n\n\n\n

      Create a style.css file within the newly created assets folder to define the layout and the style for the Tic-Tac-Toe game. This will deal with the styling of the board, cells, and any status messages.\n\n\n\n

      Code:\n\n\n\n

      h1, h2 {\n\nfont-family: 'Indie Flower', 'Comic Sans', cursive;\n\ntext-align: center;\n\n}\n\n#board {\n\nfont-family: 'Indie Flower', 'Comic Sans', cursive;\n\nposition: relative;\n\nfont-size: 120px;\n\nmargin: 1% auto;\n\nborder-collapse: collapse;\n\n}\n\n#board td {\n\nborder: 4px solid rgb(60, 60, 60);\n\nwidth: 90px;\n\nheight: 90px;\n\nvertical-align: middle;\n\ntext-align: center;\n\ncursor: pointer;\n\n}\n\n#board td div {\n\nwidth: 90px;\n\nheight: 90px;\n\nline-height: 90px;\n\ndisplay: block;\n\noverflow: hidden;\n\ncursor: pointer;\n\n}\n\n.x {\n\ncolor: darksalmon;\n\nposition: relative;\n\nfont-size: 1.2em;\n\ncursor: default;\n\n}\n\n.o {\n\ncolor: aquamarine;\n\nposition: relative;\n\nfont-size: 1.0em;\n\ncursor: default;\n\n}\n\n.win {\n\nbackground-color: beige;\n\n}\n\n\n\n

      Step 3: Update index.html\n\n\n\n

      Modifying the index.html file to reference the PyScript setup, load main.py, define the game board structure, and point to the style.css (from your assets folder) for the styling.\n\n\n\n

      Code:\n\n\n\n

      \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
      	
      
      
      
      
      
      
      

      亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

      Home Technology peripherals AI PyScript: Run Python in Your Browser Easily - Analytics Vidhya

      PyScript: Run Python in Your Browser Easily - Analytics Vidhya

      Jun 06, 2025 am 10:28 AM

      In recent years, Python has become one of the most widely used programming languages. However, Python hasn’t played a large role when it comes to web development specifically, until now. PyScript is here to change that. It is a new framework that allows you to run Python code directly on your web browser using only HTML and Python code. Regardless of your experience level, it’s really simple to use PyScript to develop interactive web apps without knowing JavaScript. In this tutorial, you will learn about PyScript, what it is, how it works, and how to create your first browser-based Python app using it.

      Table of contents
      • What is PyScript
      • How to Use PyScript for your WebApp?
      • Hands-on with PyScript
        • Step 1: Update main.py
        • Step 2: Create a CSS file
        • Step 3: Update index.html
        • Step 4: Update pyscript.toml
        • Conclusion

          What is PyScript

          PyScript is an open-source framework that bridges the gap between Python and the web. It lets you run Python code directly in your web browser. Allowing you to write interactive Python applications that run entirely on the client side, without needing a backend server. PyScript is like writing a web app with Python instead of JavaScript. You can build simple interactive web tools, dashboards, and more, all with Python.

          Key Features of PyScript
          1. Python in Browser: You can write Python code inside tags in your HTML file
          2. No Environment Setup: No need to install any additional libraries or tools. It runs in the browser.
          3. Interactivity with HTML: Easily integrates Python with HTML, CSS, and JavaScript.
          4. Powered by WebAssembly: Uses Pyodide(Python compiled to WebAssembly) to run Python in the browser.

            How to Use PyScript for your WebApp?

            Step 1: Visit the Official Website

            Visit the official website. This is the where you can explore demos, documentation, and try it yourself.

            PyScript: Run Python in Your Browser Easily - Analytics Vidhya

            PyScript: Run Python in Your Browser Easily - Analytics Vidhya

            Step 2: Set-up a Basic HTML File

            To run PyScript, you’ll need a simple HTML file that has the required framework.

            Example code:

            
            
            
            
            
            <meta charset="UTF-8" https:>
            
            <title>My First PyScript App<https:>
            
            <link rel="stylesheet" href="https:http://ipnx.cn/link/29a9f8c8460e5e2be4edde557fd83712http://ipnx.cn/link/29a9f8c8460e5e2be4edde557fd83712pyscript.nethttp://ipnx.cn/link/29a9f8c8460e5e2be4edde557fd83712latesthttp://ipnx.cn/link/29a9f8c8460e5e2be4edde557fd83712pyscript.css" https:>
            
            <script defer src="https:http://ipnx.cn/link/29a9f8c8460e5e2be4edde557fd83712http://ipnx.cn/link/29a9f8c8460e5e2be4edde557fd83712pyscript.nethttp://ipnx.cn/link/29a9f8c8460e5e2be4edde557fd83712latesthttp://ipnx.cn/link/29a9f8c8460e5e2be4edde557fd83712pyscript.js"><http://ipnx.cn/link/29a9f8c8460e5e2be4edde557fd83712script>
            
            <http://ipnx.cn/link/29a9f8c8460e5e2be4edde557fd83712head>
            
            <body>
            
            <h1>Hello from PyScript!<http://ipnx.cn/link/29a9f8c8460e5e2be4edde557fd83712h1>
            
            <py-script>
            
            name = "PyScript"
            
            print(f"Hello, {name}! You are running Python in the browser.")
            
            <http://ipnx.cn/link/29a9f8c8460e5e2be4edde557fd83712py-script>
            
            <http://ipnx.cn/link/29a9f8c8460e5e2be4edde557fd83712body>
            
            <http://ipnx.cn/link/29a9f8c8460e5e2be4edde557fd83712html><http://ipnx.cn/link/29a9f8c8460e5e2be4edde557fd83712pre>
            
            
            
            <p><strong>Step 3<http://ipnx.cn/link/29a9f8c8460e5e2be4edde557fd83712strong>: Open the HTML file in a Browser.<http://ipnx.cn/link/29a9f8c8460e5e2be4edde557fd83712p>
            
            
            
            <p>By default, there will be 3 files:<http://ipnx.cn/link/29a9f8c8460e5e2be4edde557fd83712p>
            
            
            
            <pre ><strong>main.py:<http://ipnx.cn/link/29a9f8c8460e5e2be4edde557fd83712strong> Your Python code.<br><br><strong>Index.html:<http://ipnx.cn/link/29a9f8c8460e5e2be4edde557fd83712strong> The main web page that includes PyScript.<br><br><strong>pyscript.toml:<http://ipnx.cn/link/29a9f8c8460e5e2be4edde557fd83712strong> A configuration file listing any extra Python packages you<br>want to use.<http://ipnx.cn/link/29a9f8c8460e5e2be4edde557fd83712pre>
            
            
            
            <p>Update the code files with the appropriate codes and start experimenting:<http://ipnx.cn/link/29a9f8c8460e5e2be4edde557fd83712p>
            
            
            
            <p><img src="/static/imghw/default1.png"  data-src="https:http://ipnx.cn/link/29a9f8c8460e5e2be4edde557fd83712http://ipnx.cn/link/29a9f8c8460e5e2be4edde557fd83712img.php.cnhttp://ipnx.cn/link/29a9f8c8460e5e2be4edde557fd83712uploadhttp://ipnx.cn/link/29a9f8c8460e5e2be4edde557fd83712articlehttp://ipnx.cn/link/29a9f8c8460e5e2be4edde557fd83712000http://ipnx.cn/link/29a9f8c8460e5e2be4edde557fd83712000http://ipnx.cn/link/29a9f8c8460e5e2be4edde557fd83712000http://ipnx.cn/link/29a9f8c8460e5e2be4edde557fd83712174917689770305.jpg"  class="lazy" alt="PyScript: Run Python in Your Browser Easily - Analytics Vidhya" http://ipnx.cn/link/29a9f8c8460e5e2be4edde557fd83712><http://ipnx.cn/link/29a9f8c8460e5e2be4edde557fd83712p>
            
            
            <p>You can try PyScript Playground at PyScript examples to test code snippets directly in your browser.<http://ipnx.cn/link/29a9f8c8460e5e2be4edde557fd83712p>
            
            
            
            <p><img src="/static/imghw/default1.png"  data-src="https:http://ipnx.cn/link/29a9f8c8460e5e2be4edde557fd83712http://ipnx.cn/link/29a9f8c8460e5e2be4edde557fd83712img.php.cnhttp://ipnx.cn/link/29a9f8c8460e5e2be4edde557fd83712uploadhttp://ipnx.cn/link/29a9f8c8460e5e2be4edde557fd83712articlehttp://ipnx.cn/link/29a9f8c8460e5e2be4edde557fd83712000http://ipnx.cn/link/29a9f8c8460e5e2be4edde557fd83712000http://ipnx.cn/link/29a9f8c8460e5e2be4edde557fd83712000http://ipnx.cn/link/29a9f8c8460e5e2be4edde557fd83712174917689822091.jpg"  class="lazy" alt="PyScript: Run Python in Your Browser Easily - Analytics Vidhya" http://ipnx.cn/link/29a9f8c8460e5e2be4edde557fd83712><http://ipnx.cn/link/29a9f8c8460e5e2be4edde557fd83712p>
            
            
            <h2  >Hands-on with PyScript<http://ipnx.cn/link/29a9f8c8460e5e2be4edde557fd83712h2>
            
            
            
            <p>Now that you are familiar with how the PyScript interface works, let us perform some hands-on with it.<http://ipnx.cn/link/29a9f8c8460e5e2be4edde557fd83712p>
            
            
            
            <p>We will build a two-player tic-tac-toe game.<http://ipnx.cn/link/29a9f8c8460e5e2be4edde557fd83712p>
            
            
            
            <h3  >Step 1: Update <em>main.py?<http://ipnx.cn/link/29a9f8c8460e5e2be4edde557fd83712em><http://ipnx.cn/link/29a9f8c8460e5e2be4edde557fd83712h3>
            
            
            
            <p>Add the <em>main.py<http://ipnx.cn/link/29a9f8c8460e5e2be4edde557fd83712em> file with the TicTacToe class, which contains the game logic, user interactions, and UI updates. It will use PyWeb to connect Python with HTML, making the game fully interactive within the browser.<http://ipnx.cn/link/29a9f8c8460e5e2be4edde557fd83712p>
            
            
            
            <p><strong>Code:<http://ipnx.cn/link/29a9f8c8460e5e2be4edde557fd83712strong><http://ipnx.cn/link/29a9f8c8460e5e2be4edde557fd83712p>
            
            
            
            <pre >from pyweb import pydom
            
            class TicTacToe:
            
            def __init__(self):
            
            self.board = pydom["table#board"]
            
            self.status = pydom["h2#status"]
            
            self.console = pydom["script#console"][0]
            
            self.init_cells()
            
            self.init_winning_combos()
            
            self.new_game(...)
            
            def set_status(self, text):
            
            self.status.html = text
            
            def init_cells(self):
            
            self.cells = []
            
            for i in (0, 1, 2):
            
            row = []
            
            for j in (0, 1, 2):
            
            cell = pydom[f"div#cell{i}{j}"][0]
            
            assert cell
            
            row.append(cell)
            
            self.cells.append(row)
            
            def init_winning_combos(self):
            
            self.winning_combos = []
            
            # winning columns
            
            for i in (0, 1, 2):
            
            combo = []
            
            for j in (0, 1, 2):
            
            combo.append((i, j))
            
            self.winning_combos.append(combo)
            
            # winning rows
            
            for j in (0, 1, 2):
            
            combo = []
            
            for i in (0, 1, 2):
            
            combo.append((i, j))
            
            self.winning_combos.append(combo)
            
            # winning diagonals
            
            self.winning_combos.append([(0, 0), (1, 1), (2, 2)])
            
            self.winning_combos.append([(0, 2), (1, 1), (2, 0)])
            
            def new_game(self, event):
            
            self.clear_terminal()
            
            print('=================')
            
            print('NEW GAME STARTING')
            
            print()
            
            for i in (0, 1, 2):
            
            for j in (0, 1, 2):
            
            self.set_cell(i, j, "")
            
            self.current_player = "x"
            
            experimentingself.set_status(f'{self.current_player} playing...')
            
            def next_turn(self):
            
            winner = self.check_winner()
            
            if winner == "tie":
            
            self.set_status("It's a tie!")
            
            self.current_player = "" # i.e., game ended
            
            return
            
            elif winner is not None:
            
            self.set_status(f'{winner} wins')
            
            self.current_player = "" # i.e., game ended
            
            return
            
            if self.current_player == "x":
            
            self.current_player = "o"
            
            else:
            
            self.current_player = "x"
            
            self.set_status(f'{self.current_player} playing...')
            
            def check_winner(self):
            
            """
            
            Check whether the game as any winner.
            
            Return "x", "o", "tie" or None. None means that the game is still playing.
            
            """
            
            # check whether we have a winner
            
            for combo in self.winning_combos:
            
            winner = self.get_winner(combo)
            
            if winner:
            
            # highlight the winning cells
            
            for i, j in combo:
            
            self.cells[i][j].add_class("win")
            
            return winner
            
            # check whether it's a tie
            
            for i in (0, 1, 2):
            
            for j in (0, 1, 2):
            
            if self.get_cell(i, j) == "":
            
            # there is at least an empty cell, it's not a tie
            
            return None # game still playing
            
            return "tie"
            
            def get_winner(self, combo):
            
            """
            
            If all the cells at the given points have the same value, return it.
            
            Else return "".
            
            Each point is a tuple of (i, j) coordinates.
            
            Example:
            
            self.get_winner([(0, 0), (1, 1), (2, 2)])
            
            """
            
            assert len(combo) == 3
            
            values = [self.get_cell(i, j) for i, j in combo]
            
            if values[0] == values[1] == values[2] and values[0] != "":
            
            return values[0]
            
            return ""
            
            def set_cell(self, i, j, value):
            
            assert value in ("", "x", "o")
            
            cell = self.cells[i][j]
            
            cell.html = value
            
            if "x" in cell.classes:
            
            cell.remove_class("x")
            
            if "o" in cell.classes:
            
            cell.remove_class("o")
            
            if "win" in cell.classes:
            
            cell.remove_class("win")
            
            if value != "":
            
            cell.add_class(value)
            
            def get_cell(self, i, j):
            
            cell = self.cells[i][j]
            
            value = cell.html
            
            assert value in ("", "x", "o")
            
            return value
            
            def click(self, event):
            
            i = int(event.target.getAttribute('data-x'))
            
            j = int(event.target.getAttribute('data-y'))
            
            print(f'Cell {i}, {j} clicked: ', end='')
            
            if self.current_player == "":
            
            print('game ended, nothing to do')
            
            return
            
            #
            
            value = self.get_cell(i, j)
            
            if value == "":
            
            print('cell empty, setting it')
            
            self.set_cell(i, j, self.current_player)
            
            self.next_turn()
            
            else:
            
            print(f'cell already full, cannot set it')
            
            def clear_terminal(self):
            
            self.console._js.terminal.clear()
            
            def toggle_terminal(self, event):
            
            hidden = self.console.parent._js.getAttribute("hidden")
            
            if hidden:
            
            self.console.parent._js.removeAttribute("hidden")
            
            else:
            
            self.console.parent._js.setAttribute("hidden", "hidden")
            
            GAME = TicTacToe()<http://ipnx.cn/link/29a9f8c8460e5e2be4edde557fd83712pre>
            
            
            
            <h3  >Step 2: Create a CSS file<http://ipnx.cn/link/29a9f8c8460e5e2be4edde557fd83712h3>
            
            
            
            <p>Create a <em>style.css<http://ipnx.cn/link/29a9f8c8460e5e2be4edde557fd83712em> file within the newly created <strong>assets<http://ipnx.cn/link/29a9f8c8460e5e2be4edde557fd83712strong> folder to define the layout and the style for the Tic-Tac-Toe game. This will deal with the styling of the board, cells, and any status messages.<http://ipnx.cn/link/29a9f8c8460e5e2be4edde557fd83712p>
            
            
            
            <p><strong>Code:<http://ipnx.cn/link/29a9f8c8460e5e2be4edde557fd83712strong><http://ipnx.cn/link/29a9f8c8460e5e2be4edde557fd83712p>
            
            
            
            <pre >h1, h2 {
            
            font-family: 'Indie Flower', 'Comic Sans', cursive;
            
            text-align: center;
            
            }
            
            #board {
            
            font-family: 'Indie Flower', 'Comic Sans', cursive;
            
            position: relative;
            
            font-size: 120px;
            
            margin: 1% auto;
            
            border-collapse: collapse;
            
            }
            
            #board td {
            
            border: 4px solid rgb(60, 60, 60);
            
            width: 90px;
            
            height: 90px;
            
            vertical-align: middle;
            
            text-align: center;
            
            cursor: pointer;
            
            }
            
            #board td div {
            
            width: 90px;
            
            height: 90px;
            
            line-height: 90px;
            
            display: block;
            
            overflow: hidden;
            
            cursor: pointer;
            
            }
            
            .x {
            
            color: darksalmon;
            
            position: relative;
            
            font-size: 1.2em;
            
            cursor: default;
            
            }
            
            .o {
            
            color: aquamarine;
            
            position: relative;
            
            font-size: 1.0em;
            
            cursor: default;
            
            }
            
            .win {
            
            background-color: beige;
            
            }<http://ipnx.cn/link/29a9f8c8460e5e2be4edde557fd83712pre>
            
            
            
            <h3  >Step 3: Update <em>index.html<http://ipnx.cn/link/29a9f8c8460e5e2be4edde557fd83712em><http://ipnx.cn/link/29a9f8c8460e5e2be4edde557fd83712h3>
            
            
            
            <p>Modifying the <em>index.html<http://ipnx.cn/link/29a9f8c8460e5e2be4edde557fd83712em> file to reference the PyScript setup, load <em>main.py<http://ipnx.cn/link/29a9f8c8460e5e2be4edde557fd83712em>, define the game board structure, and point to the <em>style.css<http://ipnx.cn/link/29a9f8c8460e5e2be4edde557fd83712em> (from your assets folder) for the styling.<http://ipnx.cn/link/29a9f8c8460e5e2be4edde557fd83712p>
            
            
            
            <p><strong>Code:<http://ipnx.cn/link/29a9f8c8460e5e2be4edde557fd83712strong><http://ipnx.cn/link/29a9f8c8460e5e2be4edde557fd83712p>
            
            
            
            <pre ><!doctype html>
            
            <html>
            
            <head>
            
            <!-- Recommended meta tags -->
            
            <meta charset="UTF-8">
            
            <meta name="viewport" content="width=device-width,initial-scale=1.0">
            
            <!-- PyScript CSS -->
            
            <link rel="stylesheet" href="https:http://ipnx.cn/link/29a9f8c8460e5e2be4edde557fd83712http://ipnx.cn/link/29a9f8c8460e5e2be4edde557fd83712pyscript.nethttp://ipnx.cn/link/29a9f8c8460e5e2be4edde557fd83712releaseshttp://ipnx.cn/link/29a9f8c8460e5e2be4edde557fd837122024.1.1http://ipnx.cn/link/29a9f8c8460e5e2be4edde557fd83712core.css">
            
            <!-- CSS for examples -->
            
            <link rel="stylesheet" href=".http://ipnx.cn/link/29a9f8c8460e5e2be4edde557fd83712assetshttp://ipnx.cn/link/29a9f8c8460e5e2be4edde557fd83712csshttp://ipnx.cn/link/29a9f8c8460e5e2be4edde557fd83712examples.css" http://ipnx.cn/link/29a9f8c8460e5e2be4edde557fd83712>
            
            <!-- This script tag bootstraps PyScript -->
            
            <script type="module" src="https:http://ipnx.cn/link/29a9f8c8460e5e2be4edde557fd83712http://ipnx.cn/link/29a9f8c8460e5e2be4edde557fd83712pyscript.nethttp://ipnx.cn/link/29a9f8c8460e5e2be4edde557fd83712releaseshttp://ipnx.cn/link/29a9f8c8460e5e2be4edde557fd837122024.1.1http://ipnx.cn/link/29a9f8c8460e5e2be4edde557fd83712core.js"><http://ipnx.cn/link/29a9f8c8460e5e2be4edde557fd83712script>
            
            <!-- Custom CSS -->
            
            <link href="https:http://ipnx.cn/link/29a9f8c8460e5e2be4edde557fd83712http://ipnx.cn/link/29a9f8c8460e5e2be4edde557fd83712fonts.googleapis.comhttp://ipnx.cn/link/29a9f8c8460e5e2be4edde557fd83712css?family=Indie Flower" rel="stylesheet">
            
            <link rel="stylesheet" href=".http://ipnx.cn/link/29a9f8c8460e5e2be4edde557fd83712assetshttp://ipnx.cn/link/29a9f8c8460e5e2be4edde557fd83712csshttp://ipnx.cn/link/29a9f8c8460e5e2be4edde557fd83712tictactoe.css" http://ipnx.cn/link/29a9f8c8460e5e2be4edde557fd83712>
            
            <!-- for splashscreen -->
            
            <style>
            
            #loading { outline: none; border: none; background: transparent }
            
            <http://ipnx.cn/link/29a9f8c8460e5e2be4edde557fd83712style>
            
            <script type="module">
            
            const loading = document.getElementById('loading');
            
            addEventListener('py:ready', () => loading.close());
            
            loading.showModal();
            
            <http://ipnx.cn/link/29a9f8c8460e5e2be4edde557fd83712script>
            
            <title>Tic Tac Toe<http://ipnx.cn/link/29a9f8c8460e5e2be4edde557fd83712title>
            
            <link rel="icon" type="imagehttp://ipnx.cn/link/29a9f8c8460e5e2be4edde557fd83712png" href=".http://ipnx.cn/link/29a9f8c8460e5e2be4edde557fd83712assetshttp://ipnx.cn/link/29a9f8c8460e5e2be4edde557fd83712favicon.png" http://ipnx.cn/link/29a9f8c8460e5e2be4edde557fd83712>
            
            <http://ipnx.cn/link/29a9f8c8460e5e2be4edde557fd83712head>
            
            <body>
            
            <dialog >
            
            <h1>Loading...<http://ipnx.cn/link/29a9f8c8460e5e2be4edde557fd83712h1>
            
            <http://ipnx.cn/link/29a9f8c8460e5e2be4edde557fd83712dialog>
            
            <nav  >
            
            <div >
            
            <a href="http://ipnx.cn/link/29a9f8c8460e5e2be4edde557fd83712">
            
            <img src="/static/imghw/default1.png"  data-src="https:http://ipnx.cn/link/29a9f8c8460e5e2be4edde557fd83712http://ipnx.cn/link/29a9f8c8460e5e2be4edde557fd83712img.php.cnhttp://ipnx.cn/link/29a9f8c8460e5e2be4edde557fd83712uploadhttp://ipnx.cn/link/29a9f8c8460e5e2be4edde557fd83712articlehttp://ipnx.cn/link/29a9f8c8460e5e2be4edde557fd83712000http://ipnx.cn/link/29a9f8c8460e5e2be4edde557fd83712000http://ipnx.cn/link/29a9f8c8460e5e2be4edde557fd83712000http://ipnx.cn/link/29a9f8c8460e5e2be4edde557fd83712174917690072228.png"  class="lazy" alt="PyScript: Run Python in Your Browser Easily - Analytics Vidhya" http://ipnx.cn/link/29a9f8c8460e5e2be4edde557fd83712>
            
            <http://ipnx.cn/link/29a9f8c8460e5e2be4edde557fd83712a>
            
            <a  href="" >Tic Tac Toe<http://ipnx.cn/link/29a9f8c8460e5e2be4edde557fd83712a>
            
            <http://ipnx.cn/link/29a9f8c8460e5e2be4edde557fd83712div>
            
            <http://ipnx.cn/link/29a9f8c8460e5e2be4edde557fd83712nav>
            
            <section >
            
            <h1>Tic-Tac-Toe<http://ipnx.cn/link/29a9f8c8460e5e2be4edde557fd83712h1>
            
            <script type="py" src=".http://ipnx.cn/link/29a9f8c8460e5e2be4edde557fd83712main.py" config=".http://ipnx.cn/link/29a9f8c8460e5e2be4edde557fd83712pyscript.toml"><http://ipnx.cn/link/29a9f8c8460e5e2be4edde557fd83712script>
            
            <table >
            
            <tr>
            
            <td><div  data-x="0" data-y="0"  py-click="GAME.click"><http://ipnx.cn/link/29a9f8c8460e5e2be4edde557fd83712div><http://ipnx.cn/link/29a9f8c8460e5e2be4edde557fd83712td>
            
            <td><div  data-x="0" data-y="1"  py-click="GAME.click"><http://ipnx.cn/link/29a9f8c8460e5e2be4edde557fd83712div><http://ipnx.cn/link/29a9f8c8460e5e2be4edde557fd83712td>
            
            <td><div  data-x="0" data-y="2"  py-click="GAME.click"><http://ipnx.cn/link/29a9f8c8460e5e2be4edde557fd83712div><http://ipnx.cn/link/29a9f8c8460e5e2be4edde557fd83712td>
            
            <tr>
            
            <td><div  data-x="1" data-y="0"  py-click="GAME.click"><http://ipnx.cn/link/29a9f8c8460e5e2be4edde557fd83712div><http://ipnx.cn/link/29a9f8c8460e5e2be4edde557fd83712td>
            
            <td><div  data-x="1" data-y="1"  py-click="GAME.click"><http://ipnx.cn/link/29a9f8c8460e5e2be4edde557fd83712div><http://ipnx.cn/link/29a9f8c8460e5e2be4edde557fd83712td>
            
            <td><div  data-x="1" data-y="2"  py-click="GAME.click"><http://ipnx.cn/link/29a9f8c8460e5e2be4edde557fd83712div><http://ipnx.cn/link/29a9f8c8460e5e2be4edde557fd83712td>
            
            <http://ipnx.cn/link/29a9f8c8460e5e2be4edde557fd83712tr>
            
            <tr>
            
            <td><div  data-x="2" data-y="0"  py-click="GAME.click"><http://ipnx.cn/link/29a9f8c8460e5e2be4edde557fd83712div><http://ipnx.cn/link/29a9f8c8460e5e2be4edde557fd83712td>
            
            <td><div  data-x="2" data-y="1"  py-click="GAME.click"><http://ipnx.cn/link/29a9f8c8460e5e2be4edde557fd83712div><http://ipnx.cn/link/29a9f8c8460e5e2be4edde557fd83712td>
            
            <td><div  data-x="2" data-y="2"  py-click="GAME.click"><http://ipnx.cn/link/29a9f8c8460e5e2be4edde557fd83712div><http://ipnx.cn/link/29a9f8c8460e5e2be4edde557fd83712td>
            
            <http://ipnx.cn/link/29a9f8c8460e5e2be4edde557fd83712tr>
            
            <http://ipnx.cn/link/29a9f8c8460e5e2be4edde557fd83712table>
            
            <h2 ><http://ipnx.cn/link/29a9f8c8460e5e2be4edde557fd83712h2>
            
            <button  py-click="GAME.new_game">New game<http://ipnx.cn/link/29a9f8c8460e5e2be4edde557fd83712button>
            
            <button  py-click="GAME.toggle_terminal">Hidehttp://ipnx.cn/link/29a9f8c8460e5e2be4edde557fd83712show terminal<http://ipnx.cn/link/29a9f8c8460e5e2be4edde557fd83712button>
            
            <div  hidden="hidden">
            
            <script  type="py" terminal><http://ipnx.cn/link/29a9f8c8460e5e2be4edde557fd83712script>
            
            <http://ipnx.cn/link/29a9f8c8460e5e2be4edde557fd83712div>
            
            <http://ipnx.cn/link/29a9f8c8460e5e2be4edde557fd83712section>
            
            <http://ipnx.cn/link/29a9f8c8460e5e2be4edde557fd83712body>
            
            <http://ipnx.cn/link/29a9f8c8460e5e2be4edde557fd83712html><http://ipnx.cn/link/29a9f8c8460e5e2be4edde557fd83712pre>
            
            
            
            <h3  >Step 4: Update <em>pyscript.toml<http://ipnx.cn/link/29a9f8c8460e5e2be4edde557fd83712em><http://ipnx.cn/link/29a9f8c8460e5e2be4edde557fd83712h3>
            
            
            
            <p>Updating the <em>pyscript.toml<http://ipnx.cn/link/29a9f8c8460e5e2be4edde557fd83712em> file with the necessary configuration needed by the app, including dependencies, file paths, etc. This ensures that PyScript knows how to load and run the Python code properly. Here are the contents of the <em>pyscript.toml<http://ipnx.cn/link/29a9f8c8460e5e2be4edde557fd83712em> file for our Tic-Tac-Toe application:<http://ipnx.cn/link/29a9f8c8460e5e2be4edde557fd83712p>
            
            
            
            <p><strong>Config:<http://ipnx.cn/link/29a9f8c8460e5e2be4edde557fd83712strong><http://ipnx.cn/link/29a9f8c8460e5e2be4edde557fd83712p>
            
            
            
            <pre >name = "Tic Tac Toe"
            
            description = "A Tic-Tac-Toe game written in PyScript that allows people to take turns."<http://ipnx.cn/link/29a9f8c8460e5e2be4edde557fd83712pre>
            
            
            
            <p><strong>Output:<http://ipnx.cn/link/29a9f8c8460e5e2be4edde557fd83712strong><http://ipnx.cn/link/29a9f8c8460e5e2be4edde557fd83712p>
            
            
            
            
            <iframe src="https:http://ipnx.cn/link/29a9f8c8460e5e2be4edde557fd83712http://ipnx.cn/link/29a9f8c8460e5e2be4edde557fd83712cdn.analyticsvidhya.comhttp://ipnx.cn/link/29a9f8c8460e5e2be4edde557fd83712wp-contenthttp://ipnx.cn/link/29a9f8c8460e5e2be4edde557fd83712uploadshttp://ipnx.cn/link/29a9f8c8460e5e2be4edde557fd837122025http://ipnx.cn/link/29a9f8c8460e5e2be4edde557fd8371206http://ipnx.cn/link/29a9f8c8460e5e2be4edde557fd83712recording-2.webm" loading="lazy" title="YouTube video" allowfullscreen><http://ipnx.cn/link/29a9f8c8460e5e2be4edde557fd83712iframe>
            
            
            
            
            <p>Here you go with your first project on PyScript.<http://ipnx.cn/link/29a9f8c8460e5e2be4edde557fd83712p>
            
            
            
            <h2  >Conclusion<http://ipnx.cn/link/29a9f8c8460e5e2be4edde557fd83712h2>
            
            
            
            <p>Python is being used in Data Science, AI, Automation, and in education like never before. However, there hasn’t been a native home for Python on the web until now. PyScript has arrived and fuses the simplicity of Python with the accessibility of the web. It is still maturing, but it has already created lots of opportunities for developers, educators, and learners alike.<http://ipnx.cn/link/29a9f8c8460e5e2be4edde557fd83712p></script></https:>
            </title>

      The above is the detailed content of PyScript: Run Python in Your Browser Easily - Analytics Vidhya. For more information, please follow other related articles on the PHP Chinese website!

      Statement of this Website
      The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

      Hot AI Tools

      Undress AI Tool

      Undress AI Tool

      Undress images for free

      Undresser.AI Undress

      Undresser.AI Undress

      AI-powered app for creating realistic nude photos

      AI Clothes Remover

      AI Clothes Remover

      Online AI tool for removing clothes from photos.

      Clothoff.io

      Clothoff.io

      AI clothes remover

      Video Face Swap

      Video Face Swap

      Swap faces in any video effortlessly with our completely free AI face swap tool!

      Hot Tools

      Notepad++7.3.1

      Notepad++7.3.1

      Easy-to-use and free code editor

      SublimeText3 Chinese version

      SublimeText3 Chinese version

      Chinese version, very easy to use

      Zend Studio 13.0.1

      Zend Studio 13.0.1

      Powerful PHP integrated development environment

      Dreamweaver CS6

      Dreamweaver CS6

      Visual web development tools

      SublimeText3 Mac version

      SublimeText3 Mac version

      God-level code editing software (SublimeText3)

      AI Investor Stuck At A Standstill? 3 Strategic Paths To Buy, Build, Or Partner With AI Vendors AI Investor Stuck At A Standstill? 3 Strategic Paths To Buy, Build, Or Partner With AI Vendors Jul 02, 2025 am 11:13 AM

      Investing is booming, but capital alone isn’t enough. With valuations rising and distinctiveness fading, investors in AI-focused venture funds must make a key decision: Buy, build, or partner to gain an edge? Here’s how to evaluate each option—and pr

      AGI And AI Superintelligence Are Going To Sharply Hit The Human Ceiling Assumption Barrier AGI And AI Superintelligence Are Going To Sharply Hit The Human Ceiling Assumption Barrier Jul 04, 2025 am 11:10 AM

      Let’s talk about it. This analysis of an innovative AI breakthrough is part of my ongoing Forbes column coverage on the latest in AI, including identifying and explaining various impactful AI complexities (see the link here). Heading Toward AGI And

      Kimi K2: The Most Powerful Open-Source Agentic Model Kimi K2: The Most Powerful Open-Source Agentic Model Jul 12, 2025 am 09:16 AM

      Remember the flood of open-source Chinese models that disrupted the GenAI industry earlier this year? While DeepSeek took most of the headlines, Kimi K1.5 was one of the prominent names in the list. And the model was quite cool.

      Future Forecasting A Massive Intelligence Explosion On The Path From AI To AGI Future Forecasting A Massive Intelligence Explosion On The Path From AI To AGI Jul 02, 2025 am 11:19 AM

      Let’s talk about it. This analysis of an innovative AI breakthrough is part of my ongoing Forbes column coverage on the latest in AI, including identifying and explaining various impactful AI complexities (see the link here). For those readers who h

      Grok 4 vs Claude 4: Which is Better? Grok 4 vs Claude 4: Which is Better? Jul 12, 2025 am 09:37 AM

      By mid-2025, the AI “arms race” is heating up, and xAI and Anthropic have both released their flagship models, Grok 4 and Claude 4. These two models are at opposite ends of the design philosophy and deployment platform, yet they

      Chain Of Thought For Reasoning Models Might Not Work Out Long-Term Chain Of Thought For Reasoning Models Might Not Work Out Long-Term Jul 02, 2025 am 11:18 AM

      For example, if you ask a model a question like: “what does (X) person do at (X) company?” you may see a reasoning chain that looks something like this, assuming the system knows how to retrieve the necessary information:Locating details about the co

      This Startup Built A Hospital In India To Test Its AI Software This Startup Built A Hospital In India To Test Its AI Software Jul 02, 2025 am 11:14 AM

      Clinical trials are an enormous bottleneck in drug development, and Kim and Reddy thought the AI-enabled software they’d been building at Pi Health could help do them faster and cheaper by expanding the pool of potentially eligible patients. But the

      Senate Kills 10-Year State-Level AI Ban Tucked In Trump's Budget Bill Senate Kills 10-Year State-Level AI Ban Tucked In Trump's Budget Bill Jul 02, 2025 am 11:16 AM

      The Senate voted 99-1 Tuesday morning to kill the moratorium after a last-minute uproar from advocacy groups, lawmakers and tens of thousands of Americans who saw it as a dangerous overreach. They didn’t stay quiet. The Senate listened.States Keep Th

      See all articles