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

TAG: Python python

 

评分:0

我来说两句

日历

« 2024-05-03  
   1234
567891011
12131415161718
19202122232425
262728293031 

数据统计

  • 访问量: 10575
  • 日志数: 7
  • 建立时间: 2015-08-17
  • 更新时间: 2015-11-09

RSS订阅

Open Toolbar