current position:Home>The introduction method of executing Python source code or Python source code file (novice, please enter the old bird and turn left)
The introduction method of executing Python source code or Python source code file (novice, please enter the old bird and turn left)
2022-01-31 01:20:21 【Programmer Zhang Yixiao】
「 This is my participation 11 The fourth of the yuegengwen challenge 3 God , Check out the activity details :2021 One last more challenge 」
At the beginning Python when , We always want to execute the code right away , But clearly follow the tutorial step by step , How to report errors on the full screen ?
The screenshot above appears because there is no clear distinction between when to enter python Interactive mode , When you don't need to enter python Interactive mode .
Let's distinguish what is Python Source code and Python The source code file :
- Python Source code :Python Source code , for example
print("hello world")
Copy code
- Python The source code file : One content is Python Source code files , Is similar to the doc A document is a document whose content is text . A file named hello.py The document of Python The source code file .
When you need to enter Python Interactive mode ?
When it comes to python The source code needs to enter Python Interactive mode :
- Input... At the terminal python
- Enter your... In this terminal window Python Source code
The biggest convenience of interactive mode is that you can get the execution result of code faster . One line of input gets one line of output , Very suitable for debugging simple code .
When you don't need to enter Python Interaction mode ?
When it comes to Python Source file , You don't need to enter Python Interactive mode , Call directly Python The interpreter can .
At this time, the calling format is : python python Source file path
- Access terminal
- python python Source file path
summary :
When it comes to python The source code needs to enter Python Interactive mode ;
When it comes to Python Source file , You don't need to enter Python Interactive mode , Call directly Python The interpreter can .
copyright notice
author[Programmer Zhang Yixiao],Please bring the original link to reprint, thank you.
https://en.pythonmana.com/2022/01/202201310120188324.html
The sidebar is recommended
- Python notes (20): built in high-order functions
- Python notes (17): closure
- Python notes (18): decorator
- Python notes (16): generators and iterators
- Python notes (XV): List derivation
- Python tells you what timing attacks are
- Python -- file and exception
- [Python from introduction to mastery] (IV) what are the built-in data types of Python? Figure out
- Python code to scan code to pay attention to official account login
- [algorithm learning] 1221 Split balanced string (Java / C / C + + / Python / go / trust)
guess what you like
-
Python notes (22): errors and exceptions
-
Python has been hidden for ten years, and once image recognition is heard all over the world
-
Python notes (21): random number module
-
Python notes (19): anonymous functions
-
Use Python and OpenCV to calculate and draw two-dimensional histogram
-
Python, Hough circle transformation in opencv
-
A library for reading and writing markdown in Python: mdutils
-
Datetime of Python time operation (Part I)
-
The most useful decorator in the python standard library
-
Python iterators and generators
Random recommended
- [Python from introduction to mastery] (V) Python's built-in data types - sequences and strings. They have no girlfriend, not a nanny, and can only be used as dry goods
- Does Python have a, = operator?
- Go through the string common sense in Python
- Fanwai 4 Handling of mouse events and solutions to common problems in Python opencv
- Summary of common functions for processing strings in Python
- When writing Python scripts, be sure to add this
- Python web crawler - Fundamentals (1)
- Pandas handles duplicate values
- Python notes (23): regular module
- Python crawlers are slow? Concurrent programming to understand it
- Parameter passing of Python function
- Stroke tuple in Python
- Talk about ordinary functions and higher-order functions in Python
- [Python data acquisition] page image crawling and saving
- [Python data collection] selenium automated test framework
- Talk about function passing and other supplements in Python
- Python programming simulation poker game
- leetcode 160. Intersection of Two Linked Lists (python)
- Python crawler actual combat, requests module, python to grab the beautiful wallpaper of a station
- Fanwai 5 Detailed description of slider in Python opencv and solutions to common problems
- My friend's stock suffered a terrible loss. When I was angry, I crawled the latest data of securities with Python
- Python interface automation testing framework -- if you want to do well, you must first sharpen its tools
- Python multi thread crawling weather website pictures and saving
- How to convert pandas data to excel file
- Python series tutorials 122
- Python Complete Guide - printing data using pyspark
- Python Complete Guide -- tuple conversion array
- Stroke the list in python (top)
- Analysis of Python requests module
- Comments and variables in Python
- New statement match, the new version of Python is finally going to introduce switch case?
- Fanwai 6 Different operations for image details in Python opencv
- Python crawler native code learning (I)
- Python quantitative data warehouse building series 2: Python operation database
- Python code reading (Part 50): taking elements from list intervals
- Pyechart + pandas made word cloud pictures of 19 report documents
- [Python crawler] multithreaded daemon & join() blocking
- Python crawls cat pictures in batches to realize thousand image imaging
- Van * Python | simple crawling of a planet
- Input and output of Python practice