python学习

1.字符串用单引号

2.print不用括号

3.print用%

例如 print "%s is number %d!" % ("Python", 1)

4.不用大括号,而用缩进

5.if判断时,不用小括号括起条件,然后加上冒号:

6.字符串用[]提取时,-1代表结束的字符

7.if语句

if expression:
  if_suite

if expression:
  if_suite
else:
  else_suite

if expression1:
  if_suite
elif expression2:
  elif_suite
else:
  else_suite

8.while循环

while expression:
  while_suite

9.for  in

for eachNum in range(3):
... print eachNum

10 help

help(raw_input)

11.print的逗号

print eachLine, #意思是不换行

12.open文件

fobj = open('test.py', 'r')
for eachLine in fobj:
    print eachLine,
fobj.close()

 

13.定义函数

def function_name([arguments]):
"optional documentation string"
function_suite

转载于:https://www.cnblogs.com/fanzi2009/archive/2009/07/02/1515711.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值