初试Python
01 Python简介
Python是一种跨平台的计算机程序设计语言。于1989年开发的语言,创始人范罗苏姆(Guido van Rossum),别称:龟叔(Guido)。
python具有非常多并且强大的第三方库,使得程序开发起来得心应手。
Python“信条”:人生苦短,我用python!(Life is short,you need Python。)
02 Python 版本
python 2.x 版本,官方在 2020 年停止支持,原码不规范,重复较多
python 3.x 版本,功能更加强大且修复了很多bug,原码清晰,简单
Let's not play games with semantics. The way I see the situation for 2.7 is that EOL is January 1st, 2020, and there will be no updates, not even source-only security patches, after that date. Support (from the core devs, the PSF, and python.org) stops completely on that date. If you want support for 2.7 beyond that day you will have to pay a commercial vendor. Of course it's open source so people are also welcome to fork it. But the core devs have toiled long enough, and the 2020 EOL date (an extension from the originally annouced 2015 EOL!) was announced with sufficient lead time and fanfare that I don't feel bad about stopping to support it at all.【原文链接】
03 Python擅长的领域
Web开发:Django、pyramid、Tornado、Bottle、Flask、WebPy
网络编程:Twisted、Requests、Scrapy、Paramiko
科学运算:SciPy、Pandas、lpython
GUI图形开发:wxPython、PyQT、Kivy
运维自动化:OpenStack、SaltStack、Ansible、腾讯蓝鲸
04 Python解释器(部分):
(1)Cpython(官方推荐):把python转化成c语言能识别的二进制码
(2)Jpython:把python转化成java语言能识别的二进制码
(3)其他语言解释器:把python转化成其他语言能识别的二进制码
(4)PyPy:将所有代码一次性编译成二进制码,加快执行效率(模仿编译型语言的一款python解释器)
05 2020年10月TIOBE指数
06 Python环境的安装
Windows
下载安装包:https://www.python.org/downloads/
配置环境变量:【右键计算机】-->【属性】-->【高级系统设置】-->【高级】-->【环境变量】-->【在系统变量中找到 Path,双击或编辑】-->【添加Python安装目录,如;C:\python38,切记前面有英文标点分号(win10系统变量与win7大体一致)】
Linux、Mac
无需安装,系统自带Python环境,但是可选择升级版本。
07 编写第一个Python程序
print("Hello World!")
08 编译型与解释型语言区别(补充)
- 编译型:一次性把所有代码编译成机器能识别的二进制码再运行
- 代表语言:c,c++
- 优点:执行速度快
- 缺点:开发速度慢,调试周期长
- 解释型:代码从上到下一行一行解释并运行:
- 代表语言:python,php
- 优点:开发效率快,调试周期短
- 缺点:执行速度相对慢
09 与其它编程语言的对比
C++
#include <iostream>
using namespace std;
int main()
{
cout << "Hello World";
return 0;
}
C
#include <stdio.h>
int main()
{
/* 我的第一个 C 程序 */
printf("Hello, World! \n");
return 0;
}
C#
using System;
namespace HelloWorldApplication
{
class HelloWorld
{
static void Main(string[] args)
{
/* 我的第一个 C# 程序*/
Console.WriteLine("Hello World!");
Console.ReadKey();
}
}
}
Java
public class HelloWorld {
public static void main(String []args) {
System.out.println("Hello World!");
}
}
PHP
<?php
echo 'Hello World!';
?>
Ruby
puts "Hello World!";
Go
package main
import "fmt"
func main() {
fmt.Println("Hello, World!")
}
Python
print("Hello, World!");
10 Python之禅(扩展)
import this
Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced.
In the face of ambiguity, refuse the temptation to guess.
There should be one-- and preferably only one --obvious way to do it.
Although that way may not be obvious at first unless you're Dutch.
Now is better than never.
Although never is often better than right now.
If the implementation is hard to explain, it's a bad idea.
If the implementation is easy to explain, it may be a good idea.
Namespaces are one honking great idea -- let's do more of those!
初试Python的更多相关文章
- 初试Python语法小试牛刀之冒泡排序
Python很火,心里很慌,没吃过猪肉,也要见见猪走路. 看了几天Python的语法,大概初步了解了一点点,https://www.liaoxuefeng.com/wiki/0014316089557 ...
- Python Web-第四周-Programs that Surf the Web(Using Python to Access Web Data)
1.Understanding HTML 1.最简单的爬虫 import urllib fhand=urllib.urlopen('http://www.dr-chuck.com/page1.htm' ...
- 初试PyOpenGL四 (Python+OpenGL)GPU粒子系统与基本碰撞
这篇相当于是对前三篇的总结,基本效果如下: 在初试PyOpenGL一 (Python+OpenGL)讲解Pyopengl环境搭建,网格,球体,第一与第三人称摄像机的实现.在初试PyOpenGL二 (P ...
- python性能监控初试
标 题: python性能监控初试作 者: itdef链 接: http://www.cnblogs.com/itdef/p/3990765.html 欢迎转帖 请保持文本完整并注明出处 之前性能统计 ...
- [python]初试页面抓取——抓取沪深股市交易龙虎榜数据
[python]抓取沪深股市交易龙虎榜数据 python 3.5.0下运行 没做自动建立files文件夹,需要手动在py文件目录下建立files文件夹后运行 #coding=utf-8 import ...
- Python基本语法初试
编程环境: win7旗舰版 Python 3.2.2(default, Sep 4 2011,09:51:08) 代码来源:(Python菜鸟) 代码内容: Python基本的输出语句print(& ...
- python初试牛刀
需求:在L7的一台机器上做nginx配置,然后代码分发到别的所有的机器上.由于目录中有很多配置文件,而且防止误操作,需要修改配置之前先备份原配置.然后需要在运行修改配置的脚本之前,先弹出界面,告知操作 ...
- python爬虫框架scrapy初试(二)
将该导航网站搜索出结果的页面http://www.dmoz.org/Computers/Programming/Languages/Python/Books/里面标题,及标题的超链接和描述爬下来. 使 ...
- 初试PyOpenGL二 (Python+OpenGL)基本地形生成与高度检测
在上文中,讲述了PyOpenGL的基本配置,以及网格,球形的生成,以及基本的漫游.现在利用上一篇的内容,来利用高程图实现一个基本的地形,并且,利用上文中的第三人称漫游,以小球为视角,来在地形上前后左右 ...
随机推荐
- Java并发编程之闭锁与栅栏
一.前言 闭锁与栅栏是在多线程编程中的概念,因为在多线程中,我们不能控制线程的执行状态,所以给线程加锁,让其按照我们的想法有秩序的执行. 闭锁 CountDownLatch,实例化时需要传入一个int ...
- SpringMVC-08-整合SSM之CRUD
查询书籍功能 完善Controller:BookController @Controller @RequestMapping("/book") public class BookC ...
- EasyCode插件使用及模板参考
EasyCode插件使用及模板参考 1.介绍安装 Easycode是idea的一个插件,可以直接对数据的表生成entity.controller.service.dao.mapper无需任何编码,简单 ...
- (数据科学学习手札95)elyra——jupyter lab平台最强插件集
本文示例文件已上传至我的Github仓库https://github.com/CNFeffery/DataScienceStudyNotes 1 简介 jupyter lab是我最喜欢的编辑器,在过往 ...
- golang 协程学习
协程数据传递问题 func TestGoroutineData(t *testing.T) { var wg sync.WaitGroup wg.Add(1) i := 0 go func(j int ...
- profile对比std::regex与boost::regex的性能
c++11标准库的regex比boost库的regex之间的性能差距接近5倍,这是为什么?stackflow上也找到一篇post<c++11 regex slower than python&g ...
- stringstream使用
stringstream的头文件是<sstream>,stringstream可以作为中间介质,实现字符串和数字之间的转换. 数字转string double a=213; string ...
- 关于浏览器访问iLO报错ERR_SSL_BAD_RECORD_MAC_ALERT
公司有几台HP DL380 G7服务器,ilo版本是ilo3(Integrated Lights-Out 3),ilo口配置好后,无法正常打开ilo页面 ping ilo口是通的,并且telnet 8 ...
- Group Convolution组卷积
思路按照常规卷积到组卷积来. 常规卷积: 如果输入feature map尺寸为C∗H∗W C*H*WC∗H∗W,卷积核有N NN个,输出feature map与卷积核的数量相同也是N NN,每个卷积核 ...
- ospf思维导图