- Hands-On Data Science and Python Machine Learning
- Frank Kane
- 417字
- 2021-07-15 17:15:05
Using the Canopy IDE
Moving back, I can also run the script from within the IDE. So from within Canopy, I can go to the Run menu. I can either go to Run | Run File, or click on the little play icon, and that will also execute my script, and see the results at the bottom in the output window, as shown in the following screenshot:

So that's another way to do it, and finally, you can also run scripts within this interactive prompt present at the bottom interactively. I can actually type in Python commands one at a time down, and have them just execute and stay within the environment down there:

For example, I could say stuff, make it a list call, and have 1, 2, 3, 4, and now I can say len(stuff), and that will give me 4:

I can say, for x in stuff:print x, and we get output as 1 2 3 4:
So you can see you can kind of makeup scripts as you go down in the interactive prompt at the bottom and execute things one thing at a time. In this example, stuff is a variable we created, a list that stays in memory, it's kind of like a global variable in other languages within this environment.
Now if I do want to reset this environment, if I want to get rid of stuff and start all over, the way you do that is you go up to the Run menu here and you can say Restart Kernel, and that will strike you over with a blank slate:
So now I have a new Python environment that's a clean slate, and in this case, what did I call it? Type stuff and stuff doesn't exist yet because I have a new environment, but I can make it something else, such as [4, 5, 6]; run it and there it is:

So there you have it, three ways of running Python code: the IPython/Jupyter Notebook, which we'll use throughout this book just because it's a good learning tool, you can also run scripts as standalone script files, and you can also execute Python code in the interactive command prompt.
So there you have it, and there you have three different ways of running Python code and experimenting and running things in production. So keep that in mind. We'll be using notebooks throughout the rest of this book, but again, you have those other options when the time comes.
- ASP.NET Web API:Build RESTful web applications and services on the .NET framework
- Android應(yīng)用程序開發(fā)與典型案例
- Apache ZooKeeper Essentials
- Flask Blueprints
- Getting Started with ResearchKit
- 數(shù)據(jù)結(jié)構(gòu)簡明教程(第2版)微課版
- C語言程序設(shè)計案例式教程
- Visual Basic學(xué)習(xí)手冊
- PLC編程與調(diào)試技術(shù)(松下系列)
- FPGA Verilog開發(fā)實戰(zhàn)指南:基于Intel Cyclone IV(進階篇)
- Keras深度學(xué)習(xí)實戰(zhàn)
- C語言程序設(shè)計
- Visual Basic程序設(shè)計實驗指導(dǎo)(第二版)
- Building Microservices with .NET Core
- FFmpeg開發(fā)實戰(zhàn):從零基礎(chǔ)到短視頻上線