python学习_基础1
上一篇 /
下一篇 2015-08-17 09:50:00
/ 个人分类:python
1、指定编码方式,可以输入汉字:在文件开头加入 # -*- coding: UTF-8 -*- 或者 #coding=utf-8
2、输出 print('sss')
3、输入 input('please input')
4、数据类型
1)数字:int、 long、 float、 complex
2)字符串 string1='string1' ,string2="string2",string3="""string3"""
- 切片:string1[1:5],连接 string1+string2
- 内建函数:
- string1.count()
- string1.join()
- string1.find()
3)列表 list=[123,'string',"string2"],可以修改其中的值
- 访问list[0],更新list[0]=456,删除 del list[0]
- 内建函数:
- cmp(list1,list2)
- len(list1)
- list(list1)
- max(list1)
- min(list1)
- 方法:
- list.append(obj)
- list.insert()
- list.sort()
4)元组 tuple=(123,'string',"string2"),不可以修改其中的值
5)字典 dict={'name':'john','age':18}
- 内建函数:
- dict.clear()
- dict.copy()
- dict.get(key)
- dict.items()
- dict.keys()
- dict.values()
5、循环语句
- for i in list: print()
- while i==1: print()
- if i==1: print() ; else: print()
- break
- continue
- pass
6、 文件系统
内置函数:
- open()
- close()
- read()
- write()
- seek()
- tell()
os系统函数:
- import os
- os.rename()
- os.mkdir()
- os.chdir()
- os.rmdir()
参考资料:
http://www.runoob.com/python/python-tutorial.html
相关阅读:
- python Mysql实现 (南瓜demi, 2015-6-02)
- python学习-if语句和while语句 (bjut_chen, 2015-6-05)
- python编写web测试脚本 (vs_dev, 2015-6-07)
- python 读多个文件 (南瓜demi, 2015-6-18)
- eclipse新建python项Project interpreter not specified (yanfang_zheng, 2015-6-22)
- python version 2.7 required,which was not found in the registry. (Lola1123, 2015-6-29)
- python处理excel (vs_dev, 2015-7-02)
- 有序的Dict数据结构 (sunlight426, 2015-7-27)
- python 函数参数的传递(参数带星号的说明)(转载) (槑丫头Testing, 2015-7-30)
收藏
举报
TAG:
Python
python