print()函数
print(520)
print(20.1)
print('hello word')
print(1+6)
fp=open('D:/text.text','a+')
print('hellow',file=fp)
fp.close()
print('hello,word,python')
转义字符
print('HELLO\nword')
print('hello\tword')
print('helloooo\tword')
print('hello\rword')
print('hello\bword')
print('http:\\\\www.baidu.com')
print('他说:\'你好\'')
print(r'hello\ndskjdgs')
print(chr(0b100111001011000))
print(ord('乘'))
查看保留字
import keyword
print(keyword.kwlist)
变量的定义和使用
name='玛丽亚'
print(name)
print('标识',id(name))
print('类型',type(name))
print('值',name)
name='三块'
name='撒'
print(name)
整数类型
n1=22
n2=0
n3=-9
print(n1,type(n1))
print(n2,type(n2))
print(n3,type(n3))
print('十进制',10)
print('二进制',0b1111)
print('八进制',0o444)
print('十六进制',0x4444)
浮点类型
a=3.145
print(a,type(a))
a1=1.1
a2=2.2
print(a1+a2)
from decimal import Decimal
print(Decimal('1.1')+Decimal('2.2'))
|