• 欢迎访问显哥博客,本网站纯属学习技术,绝无商业用途,欢迎小伙伴们共同学习!研究技术!QQ:52249909 加我QQ
  • 世界75亿人,这么小的概率,能认识你,是我一生的幸运,不妨加个QQ接触一下:52249909 加我QQ

【Python入门】(二)、第一个Python程序

Python开发 lixian 5年前 (2019-05-17) 19785次浏览 2个评论 扫描二维码

一、Python交互式模式

在cmd命令行下输入python,直接进入Python交互式模式,然后输入Python代码

print (‘hello world’)

注意:(1)、要让Python打印文字,可以直接用print()函数,用单引号或者双引号括起来,但不能混用单引号和双引号。
(2)、print前面不能有空格

【Python入门】(二)、第一个Python程序

二、命令行模式

在当前目录下写一个后缀为.py的文件
内容如下:

print(‘hello world’)

此文件只能在命令行模式下执行。
命令行模式下输入下面代码:

python hello.py

注意:执行Python文件只能在文件所在目录下执行python,如果不在,请切换到文件所在目录再执行

【Python入门】(二)、第一个Python程序


本站博主 , 版权所有丨如未注明 , 均为原创
转载请注明原文链接:【Python入门】(二)、第一个Python程序
喜欢 (3)

您必须 登录 才能发表评论!

(2)个小伙伴在吐槽
  1. I may need your help. I tried many ways but couldn't solve it, but after reading your article, I think you have a way to help me. I'm looking forward for your reply. Thanks.
    gate.io2023-06-04 01:49
  2. I am an investor of gate io, I have consulted a lot of information, I hope to upgrade my investment strategy with a new model. Your article creation ideas have given me a lot of inspiration, but I still have some doubts. I wonder if you can help me? Thanks.