初识Python

1. 实现整除的操作--双斜线,就算是浮点数,也会执行整除操作。

2. 幂(乘方)运算符-- **,它的优先级比取反(一元减)运算符高。

3. input的简单使用

>>> x = input("input x:")
input x:3
>>> y = input("input y:")
input y:4
>>> x*y
12

4. import命令,用于导入模块

>>> import math
>>> math.floor(29.3)
29.0

 不希望每次调用函数时都写上模块名

>>> from math import sqrt
>>> sqrt(16)
4.0

也可以引用变量来实现

>>> foo=math.sqrt
>>> foo(16)
4.0

5. str和repr的区别

>>> print repr("Hello, word!")
'Hello, word!'
>>> print repr(10000L)
10000L
>>> print str("Hello, world!")
Hello, world!
>>> print str(10000L)
10000
>>> tmp=42
>>> print "The temperature is "+repr(tmp)
The temperature is 42

6.input和raw_input的区别

>>> input("Enter a number:")
Enter a number:3
3
>>> raw_input("Enter a number:")
Enter a number:3
'3'

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值