phython ji

xiaoxiao2021-02-28  165

1.打印

print ("Hello World!")

name ="Jack"

print('name is: %s" %name)

#%d为打印数字 %r不知道打印类型时使用

2.输入

n =input("Please input:")

3.注释

单行注释:#

多行注释:'''

4.头一行编码

#coding=UTF-8

5.分支

a=12 b=2 if a==b: print(1) elif a>b: print(2) else: print(3)

python通过语句的缩进来判断语句体

6.循环

for i in Range(1,10,2):

print(i)

7.数组

lists=[1,2,'3']

lists[0]

8.字典

dicts={"1":2,"3":4} dicts.keys() dicts.values() dicts.items() zip(lists,lists) for k,v in dicts.items(): print(k,v)

9.函数

#函数 def add(a=-1,b=7): return a+b print add(1,2) print add() 10.类 11.方法

9.函数 9.函数
转载请注明原文地址: https://www.6miu.com/read-17350.html

最新回复(0)