码迷,mamicode.com
首页 > 其他好文 > 详细

phthon入门介绍

时间:2018-02-16 11:31:48      阅读:594      评论:0      收藏:0      [点我收藏+]

标签:简单的   import   name   机器   xpl   utc   交互   hello   pos   

1.基本的python语法

2.python爬虫

3.基本的数据分析

 4.做网站

5.做机器学习

 

 

1.python简介:

Python 是一种解释型语言: 这意味着开发过程中没有了编译这个环节。类似于PHP和Perl语言。

Python 是交互式语言: 这意味着,您可以在一个Python提示符,直接互动执行写你的程序。

Python 是面向对象语言: 这意味着Python支持面向对象的风格或代码封装在对象的编程技术。

Python 是初学者的语言:Python 对初级程序员而言,是一种伟大的语言,它支持广泛的应用程序开发,从简单的文字处理到 WWW 浏览器再到游戏。

 

 

2.python基本的打印语句

 

(0)import this   引入python赞美之歌

>>> import this
The Zen of Python, by Tim Peters

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 arent 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 youre Dutch.
Now is better than never.
Although never is often better than *right* now.
If the implementation is hard to explain, its a bad idea.
If the implementation is easy to explain, it may be a good idea.
Namespaces are one honking great idea -- lets do more of those!

 

 

(2)打印基本的语句:python2.x需要对汉字进行utf‘-8编码,3.x不用

Python中默认的编码格式是 ASCII 格式,在没修改编码格式时无法正确打印汉字,所以在读取中文时会报错。

解决方法为只要在文件开头加入 # -*- coding: UTF-8 -*- 或者 #coding=utf-8 就行了(注意:#coding=utf-8 的 = 号两边不要空格。)


注意:Python3.X 源码文件默认使用utf-8编码,所以可以正常解析中文,无需指定 UTF-8 编码。

注意:如果你使用编辑器,同时需要设置 py 文件存储的格式为 UTF-8,否则会出现类似以下错误信息:

 

 

打印单条语句:

>>> print("hello,word")
hello,word
>>> print("你好世界")
你好世界

 

 

 

打印多条语句(一行多条语句需要用分号隔开)

>>> print("hello,word");print("你好,世界")
hello,word
你好,世界

 

phthon入门介绍

标签:简单的   import   name   机器   xpl   utc   交互   hello   pos   

原文地址:https://www.cnblogs.com/qlqwjy/p/8450076.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!