python的简单输入输出格式

python的输入与输出:

1. python的输出:
python2: print "要打印的字符串"
python3: print("要打印的字符串")
name = "python"
print("hello %s" %(name))



sid = 1

print("hello %.3d" %(sid))




2. python的输入:
python2:
raw_input(): 接收字符串的数据;
input(): 只能接收数值;类型;


python3操作: 没有raw_input,只有input,
python3中为了避免记忆困难, 用input接收数据, 为字符串类型;


3. python中支持的数值类型: int,long,float, complex
print(type(**))可以查看变量的数据类型;

4. 数据类型的转换: 在python中, 所有的数据类型,都可以作为内置函数, 转换数据类型;


5. 如何删除内存中的变量;

aIn't= 5

print aInt

print "deleting aInt......."

del aInt

print aInt       #此时会报错,输出aInt没有定义;


猜你喜欢

转载自blog.csdn.net/qq_41891803/article/details/80066111