a=3.14159 print(a,type(a)) n1=1.1 n2=2.2 n3=2.1 print(n1+n2) print(n1+n3) from decimal import Decimal print(Decimal('1.1')+Decimal('2.2'))
print(520) print(98.5) #可以输入字符串 print('helloworld') print("helloworld") #含有运算符的表达式 print(3+1) #使用file=fp #fp=open('加文件地址')#将数据输入文件当中 如果文件不存在,就自主创建,存在就在文件后面继续追加 #print('helloworld',file=fp) #fp.close() #不进行换行输出(输出内容在一行当中) print('hello','world','python')
# 判断是否为闰年 while True: try: num=eval(input("请输入一个年份:")) except: print('输入错误年份') continue if (num %4==0 and num%100 !=0) or num %400==0: print(num,"是闰年") else: print(num,"不是闰年")
print('hello\nworld') #转义字符的首字母 n是newline的首字符标识换行 print('hello\tworld') print('helloooo\tworld') print('hello\rworld') #world将hello进行了覆盖 print('hello\bworld') #b是推一个格,把o退没了 print('http:\\\\www.baidu.com') print('老师说:\'大家好\'') #原字符 。不希望字符串中的转义字符起作用,就使用原字符,就是在字符串前面加上r或R print(r'hello\nworld') #最后一个字符不能是反斜杠