点击返回Python数据分析从入门到精通系列主页

Python编程方式有两种:

交互式编程

我们可以使用python命令来启动python解释器,然后进行编程,例如:

使用win+r,输入cmd,进入指令窗口

输入脚本:

C:\Users\cpei>python
Python 3.8.0 (tags/v3.8.0:fa919fd, Oct 14 2019, 19:37:50) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> print('hello,python!')  #打印hello,python!
hello,python!
>>> exit() #退出python

C:\Users\cpei>

脚本式编程

我们新建一个hello.py文件,然后在里面编写脚本,最后使用python hello.py执行脚本

  • 在D盘根目录下新建一个study文件夹,再在下面新建python文件夹

  •  鼠标右键,新建文本文件,然后将文件名改为hello.py

 

  • 用记事本或者editplus软件打开hello.py文件,在文件里输入

print ('hello,python')
  • 进入hello.py所在的文件夹,shift键+鼠标右键,选择powershell,弹出指令窗口

  •  输入指令:

python hello.py
  • 结果如下,正确输出了脚本的结果,打印出hello,python

 

Logo

CSDN联合极客时间,共同打造面向开发者的精品内容学习社区,助力成长!

更多推荐