Python基础(草稿)

简介: #python ex1.py### -- coding:utf-8 --print “Hello World!”print 6+2print "aa","bb"print "%s %d %i "%(aa,bb,cc)print "%d"%...

#python ex1.py

##

# -- coding:utf-8 --

print “Hello World!”

print 6+2

print "aa","bb"

print "%s %d %i "%(aa,bb,cc)

print "%d"%10

print x

print y

$r False True

string+string

print aa,bb 逗号即空格

print "."*10

formater="%r %r %r %r"

print formater%(1,2,3,4)

%r everything

\n 换行

"""

xx

yy

xx

yy

"""  #三个引号代表多行

获取用户输入 raw_input()

raw_input("how old are you")

pydoc raw_input

传参数

from sys import argv

script,first,second,third=argv #脚本名字,变量1,2,3

a=open(filename)

a.read()

from sys import argv

script,filename=argv

file=open(filename)

file.read()

file.readline()

file.truncate()

file.seek(0)

file.write("sss")

file.close()

from sys import argv

from os.path import exists

script,ffile,tfile=argv

input=open(ffile)

indata=input.read()

len(indata)  ##len

exists(tfile)  ##exists

output.write(indata)

output.close()

input.close()

def funt(a1,a2)

print "%r %r"%(a1,a2)

return 1

funt(1,2)

string.split(' ')

string.pop(0)

if xx:

print xx

if xx:


elif  xx:


else:

    xx

the_count=[1,2,3,4,5]

for nu in the_count:

print nu

for i in range(1,5)

num=[]

num.append(i)

a=num[1]

字典 del

from random import randint

randint(0,5)

class Employee(Person):

def __init__(self,a,b):

#######pip  distribute  nose  virtualenv

try:

except :



string.upper()

string.lower()

string.title()  首字母大写

string.strip()

string.rstrip()

string.lstrip()

str(23)

sss=[]

sss.append()

sss.insert(0,'aa')

del sss[0]

sss.pop()  delete the last

sss.pop(0)

sss.remove('aa')

sss.sort()

sss.sort(reverse=True)  永久性排序

sorted(sss)    临时排序

sss.reverse()

sss[-1] 最后一个元素

for a in sss:

print(a) #缩进即关系

for a in range(1,7):

print(a)

sss=list(range(1,8))

sss=list(range(2,11,2))

min(sss)

max(sss)

sum(sss)

sss[0:3]

sss[0:]

aaa=sss[:]

sss=(111,2222)  #不可更改

for i in range(1,5):

if i<=3:

print(i)

else:

print(i)

aaa={1:333,2:3333}

aaa[1]

del

for key,value in aaa.items():

for a in aaa.keys():

sorted(aaa.keys())

aaa.values()

set(aaa.values())  不重复的值

raw_input()

int()    转成数字

break

continue

def gree()

print

def gree(arg1='aaa')

print

while aaa:

print

def gree(*arg)

print

from modulename import fun1,fun2,fun3

import pp as p

p.fun2()

from modulename import *

#################################################################

class Dog(object):

def __init__(self,name,age)

def sit(self)

class Dog(Cat):

def __init__(self):

super(Dog,self).__init__()

from Dog import Dog

from Dog import Dog,Cat

import Dog as hh

hh.cc()

from Dog import *

######################################################################

with open('a.txt') as fi:

fi.read()

print

readline()

with open('a.txt','w') as fi:

fi.write('aa\n')

with open('a.txt','a') as fi:

fi.write('aa')

try:

xx

except xx:

pass

import json

json.dump()

json.load()

####################################################################



aa.append

aa.insert

for a in aa:

print(a)

aa[0][1][3]

isinstance(aa,list)

##

for each_item in movies:

if isinstance(each_item,list):

for ne in each_item:

print(ne)

else:

print(each_item)

##

list()

range

enumerate

int

id

next()

#######

pypi

#####

thefile=open('xx.txt')

thefile.close()

import os

os.getcwd()

os.chdir('')

os.getcwd()

data=open()

data.seek(0)

data.close()

(a,b)=string.split(':')

print(a)

print(b)

string.find(':')

if string.find(':')==-1

xx

try:

except:

pass

file.open

file.readline

file.close

file.find

string.strip

string.lstrip

string.rstrip

out=open('xx.txt','w')

print("xxx",file=out)

out.close()

try:

except:

finally:

try:

with open('xx.txt','w') as data:

print('sss',file=data)

except:

print('error')

with 帮助关闭文件

sys.stdout

sys.stdint

#####################

###二进制读写文件

import pickle

with open('xx.pickle','wb') as aa:

pickle.dump('xxx',aa)

with open('xx.pickle','rb') as bb:

ali=pickle.load(bb)

locals() 返回当前作用域的变量集合

##################

data.sort()

sorted(data)

secs=[m*60 for m in mins]

sanitize(t)  转时间格式

set()

aa[0:3]

class Aa(object):

def __init__(self):

class Nextlist(list):

dict()  空字典

#######################################

目录
相关文章
|
前端开发 测试技术
软件测试|selenium+python基础方法封装(二)
软件测试|selenium+python基础方法封装(二)
182 0
软件测试|selenium+python基础方法封装(二)
|
Web App开发 Java 测试技术
软件测试|selenium+python基础方法封装(一)
软件测试|selenium+python基础方法封装(一)
229 0
软件测试|selenium+python基础方法封装(一)
|
C语言 Python
通过题目入门python基础1
简介:本文通过,python的基础题目,带领大家入门python的基础语法,以实用主义为主。
215 0
通过题目入门python基础1
|
数据安全/隐私保护 Python
Python操作ppt和pdf基础
Python操作ppt和pdf基础
331 0
Python操作ppt和pdf基础
|
Python Windows
Python操作word基础
Python操作word基础
217 0
Python操作word基础
|
Python
Python操作excel基础
Python操作excel基础
154 0
Python操作excel基础
|
机器学习/深度学习 存储 人工智能
【paddle领航团基础python课程】三岁水课—结营大作业
【paddle领航团基础python课程】三岁水课—结营大作业
151 0
【paddle领航团基础python课程】三岁水课—结营大作业
|
Java C语言 Python
【paddle领航团基础python课程】三岁水课—python基础
大家好,这里是三岁,别的不会,擅长白话,今天就是我们的白话系列,内容就是大家看的迷迷茫茫的python基础,由于python是自学的,我也翻看了很多的教学视频和书籍,也看过部分的文档,写过自己的心得与笔记,那么接下看看,让我们一起来看看内容
124 0
【paddle领航团基础python课程】三岁水课—python基础
|
分布式计算 Python
python基础进阶 高阶函数基础
大家好,这里是三岁接下来带来的是传说中的高阶函数,如有不足请大家多多指出
130 0
python基础进阶 高阶函数基础
下一篇
无影云桌面