Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Py记录:形式,变量,序列,列表 (2016.05.10) #1

Open
xhl2791188 opened this issue May 10, 2016 · 0 comments
Open

Py记录:形式,变量,序列,列表 (2016.05.10) #1

xhl2791188 opened this issue May 10, 2016 · 0 comments

Comments

@xhl2791188
Copy link
Owner

python的三种文件形式,包括 .py .pyc .pyo

执行方式都是一样的 最常见的为.py形式。
一般执行方式可以用 python命令
还可以在代码中写入python‘的路径 #!/usr/bin/python 然后给.py文件加上权限 chmod +x 1.py 然后可以用 ./1.py 执行文件

// id(变量名) 可以查看所对应的内存位置
//type(变量名)可以查看变量所对应的类型
//反斜杠""作为转义字符

变量命名规则和运算符

从键盘输入:raw_input() //默认是输入的字符串格式 可以强制转型为int -> int(raw_input())
and:表示逻辑与; or:表示逻辑或; not:表示逻辑非

字符串的基本操作

定义方法:' ' " " """ """
eg:str="abcde"
str[0] str[1:3] str[::2]

序列的基本操作

len() in max() min() + * com(str1,str2)

元组的基本操作

定义:eg:t=("Jack",30,"male")
基本操作同字符串类似,可以通过索引和切片。

列表的基本操作

定义:eg: List=["Jerry",34,"male"]
List[1] List.append() List.remove(List[]) del(List[]) List[] = x var in List

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant