All About Python
Part one: Learn the Basics
Hello, World!
print "Hello,World!"
Variables and Types
Python is completely object oriented, and not "statically typed.
You don't need to delcare variables before using them, or delcare
their type. Every variable in Python is an object.
Numbers:
Python supports two types of numbers -integers and floating point numbers.(It also suports complex numbers)
To define an integer, use the following syntax:
aint = 7
To define a floating point number, you may use one of the following notations:
afloat = 7.0
anotherfloat = float(7)
Strings are defined either with a single quote or a double quotes:
astring = 'hello'
anotherstring = "hello"
The difference between the two is that using double quotes makes it easy to include apostrophes (whereas these would terminate the string if using single quotes)
There are additional variations on defining strings that make it easier to include things such as carriage returns.
backslashes and unicode characters.
Lists are very similar to arrays.They can contain any type of variable.Lists can aslo be iterated over in a very simple manner.
mylist = []
mylist.append(1)
mylist.append(2)
mylist.append(3)
# prints out 1,2,3
for x in mylist:
print x
All About Python的更多相关文章
- Python中的多进程与多线程(一)
一.背景 最近在Azkaban的测试工作中,需要在测试环境下模拟线上的调度场景进行稳定性测试.故而重操python旧业,通过python编写脚本来构造类似线上的调度场景.在脚本编写过程中,碰到这样一个 ...
- Python高手之路【六】python基础之字符串格式化
Python的字符串格式化有两种方式: 百分号方式.format方式 百分号的方式相对来说比较老,而format方式则是比较先进的方式,企图替换古老的方式,目前两者并存.[PEP-3101] This ...
- Python 小而美的函数
python提供了一些有趣且实用的函数,如any all zip,这些函数能够大幅简化我们得代码,可以更优雅的处理可迭代的对象,同时使用的时候也得注意一些情况 any any(iterable) ...
- JavaScript之父Brendan Eich,Clojure 创建者Rich Hickey,Python创建者Van Rossum等编程大牛对程序员的职业建议
软件开发是现时很火的职业.据美国劳动局发布的一项统计数据显示,从2014年至2024年,美国就业市场对开发人员的需求量将增长17%,而这个增长率比起所有职业的平均需求量高出了7%.很多人年轻人会选择编 ...
- 可爱的豆子——使用Beans思想让Python代码更易维护
title: 可爱的豆子--使用Beans思想让Python代码更易维护 toc: false comments: true date: 2016-06-19 21:43:33 tags: [Pyth ...
- 使用Python保存屏幕截图(不使用PIL)
起因 在极客学院讲授<使用Python编写远程控制程序>的课程中,涉及到查看被控制电脑屏幕截图的功能. 如果使用PIL,这个需求只需要三行代码: from PIL import Image ...
- Python编码记录
字节流和字符串 当使用Python定义一个字符串时,实际会存储一个字节串: "abc"--[97][98][99] python2.x默认会把所有的字符串当做ASCII码来对待,但 ...
- Apache执行Python脚本
由于经常需要到服务器上执行些命令,有些命令懒得敲,就准备写点脚本直接浏览器调用就好了,比如这样: 因为线上有现成的Apache,就直接放它里面了,当然访问安全要设置,我似乎别的随笔里写了安全问题,这里 ...
- python开发编译器
引言 最近刚刚用python写完了一个解析protobuf文件的简单编译器,深感ply实现词法分析和语法分析的简洁方便.乘着余热未过,头脑清醒,记下一点总结和心得,方便各位pythoner参考使用. ...
- 关于解决python线上问题的几种有效技术
工作后好久没上博客园了,虽然不是很忙,但也没学生时代闲了.今天上博客园,发现好多的文章都是年终总结,想想是不是自己也应该总结下,不过现在还没想好,等想好了再写吧.今天写写自己在工作后用到的技术干货,争 ...
随机推荐
- Mysql大范围分页优化案例
在BBS线上业务抓到如下分页SQL: meizu_bbs meizu_bbs Query Sending data , meizu_bbs meizu_bbs Query Sending data , ...
- 一条SQL查出当月的每一天
from master..spt_values ),,),'2013-02-03')+'-01' as datetime)) 结果: 返回带有年月日的日期 ),),) AS datetime) fro ...
- OAF_开发系列29_实现OAF中批次处理迭代器RowSet/RowSetIterator(案例)
20150814 Created By BaoXinjian
- RMQ训练题 codevs 1291 火车线路 已经搞定
就是线段树维护区间的最小值 但是要注意 本题坑人的地方 是 a到b站 实际上是维护a到b-1 因为b站已经下车了 我勒个去呀 #include<iostream> #include ...
- maven配置多模块项目事例
limit-parent <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http:// ...
- Vs2015智能提示英文?
Vs2015智能提示英文? 装了vs2015代码的智能提示全部变成英文了 找到这个目录 C:\Program Files (x86)\Reference Assemblies\Microsoft\ ...
- 同时闪烁多个要素代码(ArcEngine)
/// <summary> /// 根据查询条件构造/// </summary> /// <param name="where">查询条件< ...
- [SQL]收缩数据库日志
SELECT NAME, recovery_model_desc FROM sys.databases --查看数据库的模式 ALTER DATABASE TOMS SET RECOVERY SIMP ...
- *按类的某一字段排序(Lv)
给定一个student类,类中有两个属性ID,Score.对一组student类对象排序,写出方法.
- Oauth2.0
注:Access token 为第三方平台的token,在用户授权时使用Refresh Token为用户的token get/post参数时,一般采用字典排序