DKT
  • DKT
  • Language
    • English
      • English Daily Works Tracking
  • Programming
    • Basic
      • 树
    • VPS NOTES
    • Java9&10
    • Spring boot
      • Mastering Spring Boot 2.0
    • Hardware
      • Orange Pi
    • Project
      • Picture Smart Management 照片智能管理
    • Java Debug
    • Java VM Options
    • Java ByteBuffer
    • Linux Command
    • 设计模式 Design Pattern
    • Python learning
    • Java Basic
    • Java JNI
    • Reactor
  • Read
    • 电影Mark
    • 2018人民日报推荐书单
  • Tech
    • SSL
    • Docker
    • MySQL 主从复制搭建
  • Tool
    • Useful Tools List
    • Git Cheat Sheet
    • gitignore
    • apache-maven2
    • VirtualBox
    • Markdown
Powered by GitBook
On this page
  • 初始Python
  • Python好处
  • 安装Python
  • 数据结构 列表 - 数组
  • 迭代 - 循环
  • 条件表达式
  • 注意项
  1. Programming

Python learning

初始Python

Python好处

便捷,快速,功能强大

安装Python

官网下载安装文件安装Python 3

使用安装包自带的IDLE进行编写代码

数据结构 列表 - 数组

movies = ["The Holy Grail","The Life of brain"]

Python不需要声明变量类型

列表通过下标访问数据

print(movies[0])

列表是一个集合对象,所以提供特有的方法

len(movies) 
movies.appen("The Meaning of Life")
movies.pop()
movies.extend(["Another 1","Another 2"])
movies.remove("Another 1")
movies.insert(0,"Another 3")

列表可以放置混合类型的数据

迭代 - 循环

for movie in movies:
    print(movie)

语法:

​ for 目标标识符 in 列表 :

​ 列表处理代码

count = 0
while count < len(movies):
    print(movies[count])
    count = count+1

while循环和for循环作用一样

条件表达式

if isinstance(movies,list):
    print(movies)
else:
    print("not list")

注意项

字符串

单引号和双引号都可以创建字符串,只要前后一致即可

在一个字符串中包含双引号

str = "includ quote \" "
str = 'includ quote " '

命名规则

名字以一个字母或下划线开头,后面可以包含任一字母、数字、/、下划线

区分大小写

BIF

built in function, python 3中大约有70个BIF

在IDLE shell中输入:

dir(__builtins__)

可以查看所有BIF的列表

输入:

help(isinstance)

可以查看isinstance()的功能描述

Previous设计模式 Design PatternNextJava Basic

Last updated 6 years ago