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的更多相关文章

  1. Python中的多进程与多线程(一)

    一.背景 最近在Azkaban的测试工作中,需要在测试环境下模拟线上的调度场景进行稳定性测试.故而重操python旧业,通过python编写脚本来构造类似线上的调度场景.在脚本编写过程中,碰到这样一个 ...

  2. Python高手之路【六】python基础之字符串格式化

    Python的字符串格式化有两种方式: 百分号方式.format方式 百分号的方式相对来说比较老,而format方式则是比较先进的方式,企图替换古老的方式,目前两者并存.[PEP-3101] This ...

  3. Python 小而美的函数

    python提供了一些有趣且实用的函数,如any all zip,这些函数能够大幅简化我们得代码,可以更优雅的处理可迭代的对象,同时使用的时候也得注意一些情况   any any(iterable) ...

  4. JavaScript之父Brendan Eich,Clojure 创建者Rich Hickey,Python创建者Van Rossum等编程大牛对程序员的职业建议

    软件开发是现时很火的职业.据美国劳动局发布的一项统计数据显示,从2014年至2024年,美国就业市场对开发人员的需求量将增长17%,而这个增长率比起所有职业的平均需求量高出了7%.很多人年轻人会选择编 ...

  5. 可爱的豆子——使用Beans思想让Python代码更易维护

    title: 可爱的豆子--使用Beans思想让Python代码更易维护 toc: false comments: true date: 2016-06-19 21:43:33 tags: [Pyth ...

  6. 使用Python保存屏幕截图(不使用PIL)

    起因 在极客学院讲授<使用Python编写远程控制程序>的课程中,涉及到查看被控制电脑屏幕截图的功能. 如果使用PIL,这个需求只需要三行代码: from PIL import Image ...

  7. Python编码记录

    字节流和字符串 当使用Python定义一个字符串时,实际会存储一个字节串: "abc"--[97][98][99] python2.x默认会把所有的字符串当做ASCII码来对待,但 ...

  8. Apache执行Python脚本

    由于经常需要到服务器上执行些命令,有些命令懒得敲,就准备写点脚本直接浏览器调用就好了,比如这样: 因为线上有现成的Apache,就直接放它里面了,当然访问安全要设置,我似乎别的随笔里写了安全问题,这里 ...

  9. python开发编译器

    引言 最近刚刚用python写完了一个解析protobuf文件的简单编译器,深感ply实现词法分析和语法分析的简洁方便.乘着余热未过,头脑清醒,记下一点总结和心得,方便各位pythoner参考使用. ...

  10. 关于解决python线上问题的几种有效技术

    工作后好久没上博客园了,虽然不是很忙,但也没学生时代闲了.今天上博客园,发现好多的文章都是年终总结,想想是不是自己也应该总结下,不过现在还没想好,等想好了再写吧.今天写写自己在工作后用到的技术干货,争 ...

随机推荐

  1. .pyc是个什么鬼?

    1. Python是一门解释型语言? 我初学Python时,听到的关于Python的第一句话就是,Python是一门解释性语言,我就这样一直相信下去,直到发现了*.pyc文件的存在.如果是解释型语言, ...

  2. 黄聪:GeckoWebBrowser多窗口独立cookie

    using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; usin ...

  3. vs2012 发布网站时,发布目录为空

    当我使用Release Any CPU时为空 使用Release X86就正常发布了 奇怪. 之后再切换回 Release Any CPU时正常发布. 在生成时可以尝试设置好生成配置,先生成,再发布.

  4. XML编程知识点总结

    DOM和SAX DOM的全称是Document Object Model,也即文档对象模型.基于DOM的XML分析器将一个XML文档转换成一个对象模型的集合,应用程序挣是通过对这个对象模型的操作,来实 ...

  5. Redis内存使用优化与存储

    抄自http://www.infoq.com/cn/articles/tq-redis-memory-usage-optimization-storage 本文将对Redis的常见数据类型的使用场景以 ...

  6. 带无缝滚动的轮播图(含JS运动框架)-简洁版

    昨天写的神逻辑,今天终于解决,经过大家的商讨,终于研究出来一套简单的代码!!! js代码如下: <script> window.onload = function() { var oWra ...

  7. CentOS7 配置阿里云yum源

    1)下载repo文件 wget http://mirrors.aliyun.com/repo/Centos-7.repo 2)备份并替换系统的repo文件 cp Centos-7.repo /etc/ ...

  8. Entity Framework 学习笔记

    1.自定义数据库链接字符串上下文 public class PetDbContext : DbContext { public PetDbContext() : base("name=Dem ...

  9. tomcat 9.0配置管理员用户名和密码

    登录后,可以管理查看发布网站的信息,岗安装好的tomcat是没有管理密码的,可以在配置文件中修改. 在conf/tomcat-users.xml的文件中修改配置,默认的角色用户是被注销掉的.我去掉注释 ...

  10. Request与session与application的区别

    (1)request的setAttribute与getAttribute方法一般都是成对出现的,首先通过setAttribute方法设置属性与属性值,然后通过getAttribute方法根据属性获取到 ...