目录

Python学习篇一-新建Python文件

Python学习篇(一) 新建Python文件

文章目录


前言

这年头,要是说自己不会Python,就感觉有点尬了,赶紧学习起来。

https://i-blog.csdnimg.cn/blog_migrate/4c5bde886c13fe6cc436dfdc75e82073.png#pic_center

一、Python的自述

Python号称对初学者最好的语言。并且能帮我们做这么多东西,学了也不亏。

https://i-blog.csdnimg.cn/blog_migrate/61648bf005aa40d4bbecd2e92dd44a21.png

https://i-blog.csdnimg.cn/blog_migrate/6842eca88a0e0698d35ab73496eb65e4.png

https://i-blog.csdnimg.cn/blog_migrate/a1a515ed25324c591430d2a3a1b9041e.png

二、Python3.8的安装

进入这个网址找到3.8.1的版本,下载可执行文件,点击就可以下载。直接安装就行了。也不用你弄什么环境变量啥的。我们学习一般用pycharm后面会讲到。学会了不管在哪个IDE上跑都是一样的道理。

https://i-blog.csdnimg.cn/blog_migrate/ca38d185e4b8c600662b9718f82997a5.png

https://i-blog.csdnimg.cn/blog_migrate/c1e243b9ca6019fdd6fe6a8991b4b9e1.png

三、Pycharm 2018.3.5的安装

下载PyCharm,也是,我们一般用的是社区版的,因为是免费的。

https://i-blog.csdnimg.cn/blog_migrate/f5e8fe67774b18b60b175695dee6f8bb.png

https://i-blog.csdnimg.cn/blog_migrate/8133138bd7afd8e4e1f0bb1de9127216.png

https://i-blog.csdnimg.cn/blog_migrate/66ead33a590e78b327bbdd7731d6fdf4.png

四、新建Python文件

新建Python文件之前,先新建项目,起名,然后指定存放位置。我们一般可以新建一个文件夹来专门存放我们的Python文件。

点击file,选择Python文件

https://i-blog.csdnimg.cn/blog_migrate/a899b25e587145f3ae5eb0779c6a9c6f.png

https://i-blog.csdnimg.cn/blog_migrate/ec1d3a2f845dc1a44e452ed3e7eade19.png

修改字体,因为默认的有点小,如下图选择setting,editor。

https://i-blog.csdnimg.cn/blog_migrate/4b4f6aede65e13be9ce4fe0070bdb021.png

https://i-blog.csdnimg.cn/blog_migrate/8444b8615f04ecf4363cebd0cdd65797.png

五、print函数

可以将你展示的东西在IDE或者在标椎的控制台上显示

https://i-blog.csdnimg.cn/blog_migrate/fa34efbd26ac2f62ec8a879cbc9e9ce2.png

https://i-blog.csdnimg.cn/blog_migrate/bc96e11e86fb67860b6e5833840e3fa2.png

5.1输出在控制台

https://i-blog.csdnimg.cn/blog_migrate/a694bc0e36b822232bf1dc67054fd1dc.png

https://i-blog.csdnimg.cn/blog_migrate/e4e78c67610b1bcf05a134dfe15df4db.png

5.2 输出在文件

如果文件不存在就创建,文件存在就在原有的内容上追加

https://i-blog.csdnimg.cn/blog_migrate/2ecf231a916054f55cd52a61fb885098.png

https://i-blog.csdnimg.cn/blog_migrate/966924ec5556fb3c27493a6e9f38cd3e.png

https://i-blog.csdnimg.cn/blog_migrate/78993ddfb3e0c07a25fcc532a3a0ec4f.png

如果我不想换行输出怎么办嘞

https://i-blog.csdnimg.cn/blog_migrate/1f702ec40797b31b597e465aed18b9c7.png

https://i-blog.csdnimg.cn/blog_migrate/8d99c7cc53138af5a3faec17ea107061.png

同时我们也看一下E盘,在原有的基础上追加

https://i-blog.csdnimg.cn/blog_migrate/a7502ffad66d56d6d851e38f12e2797a.png

六、Python中的转义字符

https://i-blog.csdnimg.cn/blog_migrate/9119b312138640729bc291b7c5972d79.png

https://i-blog.csdnimg.cn/blog_migrate/59263111372b69cf7df744ac89f2fd41.png

https://i-blog.csdnimg.cn/blog_migrate/ef25281f0b2bd52c589052d27690a0b9.png

\t注意事项,什么时候重开一个制表位,取决于你\t之前是否占满制表位

https://i-blog.csdnimg.cn/blog_migrate/337ab3e5785fe56f33ba1afa6b5fefe7.png

https://i-blog.csdnimg.cn/blog_migrate/03b7820222a40c84e89c2f16c0bb5119.png

https://i-blog.csdnimg.cn/blog_migrate/da6d7d840818e2ed6d7fe318e0bb2630.png

https://i-blog.csdnimg.cn/blog_migrate/7e38712f075374c324faa1f1b28238a9.png

总结

以上就是今天要讲的内容,本文仅仅简单介绍了Python的使用,我们后续继续学习。