Python 学习(一)基础语法

1.字符串 单双引号,多行字符用三引号

2.字符串链接可以用“+”号

3.数字自增运算符用+=,自减-=

4.科学计算,3.8e16,3.8e-13

5.3**5  3的五次方

6.数据类型,str(),float(),int()强制转换,type()可获取变量类型

7.输入:raw_input

   print “Enter your name: ”

   somebody=raw_input()

   print "hi",somebody,"how are you today"


逗号,会把 字符串链接到一起,

print “My”,

print "name",

print "is",

print "Dave"

结果为:  My name is Dave.

8.从互联网读取文件

import urllib

file=urllib.urlopen("http://www.aa.bb.com/message.txt")

message=file.read();

print message

9.条件判断

if answer >=10:

   print .....

elif answer >=5:

     print ....

else:

     print "you got ..."

或者:

 if  age >=8:

    print "you got "

else:

    print "sorry"

9. 条件中的and 相当于&

if age >=8 and grade >=3:

  print "you can play this game"

else:

   print "sorry"

10.or 或条件


 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值