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线上问题的几种有效技术
工作后好久没上博客园了,虽然不是很忙,但也没学生时代闲了.今天上博客园,发现好多的文章都是年终总结,想想是不是自己也应该总结下,不过现在还没想好,等想好了再写吧.今天写写自己在工作后用到的技术干货,争 ...
随机推荐
- 【sql】之查询昨天的记录
http://blog.csdn.net/cangchen/article/details/44978531
- android-23 View.java - dispatchTouchEvent源码
public class View implements Drawable.Callback, KeyEvent.Callback, AccessibilityEventSource { /** * ...
- The server encountered an internal error that prevented it from fulfilling this request.
type Exception report message Request processing failed; nested exception is org.mybatis.spring.MyBa ...
- SQLite常用语句
// 错误存储路径 - (NSString *)dataFilePath{ NSString *dbPath = [NSSearchPathForDirectoriesInDomains(NSLibr ...
- 解析PHP正则提取或替换img标记属性
<?php/*PHP正则提取图片img标记中的任意属性*/$str = '<center><img src="/uploads/images/20100516000. ...
- iOS 跳转至AppStore评分页面
iOS7之前: [[UIApplication sharedApplication]openURL:[NSURL URLWithString:@"itms-apps://ax.itunes. ...
- 集合类 toArray(T[])
HashSet<String> deDupe = new LinkedHashSet<>(Arrays.asList(origParams.getParams(paramNam ...
- javascript面向对象之一
问题:怎么动态设置和读取一个对象的属性? <script type="text/javascript"> function User(property){ for( ...
- 【HOW】用PowerShell脚本修改用户配置文件属性显示次序
首先将如下脚本保存为PowerShell文件,如:ReorderUserProfileProperty.ps1. 在执行此脚本时,如果不输入任何参数,将列出所有用户配置文件属性的名称和显示次序:如果只 ...
- 修改Oracle字符集为 ZHS16GBK
SQL*Plus: Release 11.2.0.1.0 Production on Wed Aug 10 13:12:48 2016 Copyright (c) 1982, 2009, Oracle ...