python如何执行python程序
安装完Python在Windows或Linux中的终端中直接输入python即进入Python交互会话模式。
Python交互模式有以下几个注意点:
1.只能够输入Python命令
在Python交互模式下输入Python代码,而不要输入系统的命令。
2.在交互模式下打印语句不是必须的
在交互模式下不需要输入完整的打印语句,解释器自动打印表达式的结果,但是在文件中则需要写print语句来打印结果。
3.提示符的变换和复合语句
当在交互模式下输入两行或多行的复合语句时,提示符会由>>>变成…;如果要结束复合语句的输入并执行它,那么必须按下Enter键两次,复合语句才会被执行。
4.交互提示模式一次运行一条语句
当你想测试某一条命令的时候,交互模式是一个很好的测试方法,输入然后回车即可看到执行结果,非常方便,当然对于复合语句来说,只要最后按两次Enter键即可运行代码,看到执行结果。
第一段脚本
在命名为script1.py的文件中输入以下代码:
importsys#Loadalibrarymodule
print(sys.platform)
print(2**100)#Raise2toapower
x='Spam!'
print(x*8)
importsys是导入一个Python模块,用于获取系统平台的名称
print(sys.platform)是输出当前系统的名称,是linux系统还是Windows系统
使用命令行运行文件
pythonscript1.py
以上内容为大家介绍了python培训之如何执行python程序,希望对大家有所帮助,如果想要了解更多Python相关知识,请关注IT培训机构:千锋教育。

猜你喜欢LIKE
相关推荐HOT
更多>>
python里glob模块怎么用?
python里glob模块怎么用?本文教程操作环境:windows7系统、Python3.9.1,DELLG3电脑。简单介绍:匹配一定的格式文件和文件夹。包含函数:1、glo...详情>>
2023-11-14 23:59:20
python中time.gmtime是什么
python中time.gmtime是什么下面我们就time.gmtime函数的概念、语法、参数、返回值、实例分别进行讲解。1.概念gmtime是把日期和时间转换为格林威...详情>>
2023-11-14 21:58:02
python使用OpenCV画图
python中使用OpenCV画图OpenCV的强大之处的一个体现就是其可以对图片进行任意编辑,处理。下面的这个函数最后一个参数指定的就是画笔的大小1、...详情>>
2023-11-14 19:49:08
python流式读取大文件的两种方法
python流式读取大文件的两种方法1、使用read方法分块读取使用更底层的file.read()方法,与直接循环迭代文件对象不同,每次调用file.read(chunk_...详情>>
2023-11-14 16:48:08热门推荐
python里glob模块怎么用?
沸python中series转dataframe的两种方法
热python实现矩阵乘法运算的几种方法
热pandas遍历dataframe的方法有哪些
新python中time.gmtime是什么
python中RNN和LSTM的基本介绍
Python中for循环进行字典迭代
Python中哈希结构有哪几种?
python使用OpenCV画图
python绝对和相对导入的介绍
python标识符是什么意思?
python中如何查看stdin编码?
python如何访问列表元素?
python如何提取文本信息?
技术干货






