摘要: 1 import math2 print math.sin (0.5)3 print math.cos (0.5)关键点:1、sin、cos等数学符号后面要加括号(),括号内的参数为弧度制表示法(我也忘了什么是弧度制了。。。)2、调用sin、cos的时候,要用math.sin(),math.co... 阅读全文
posted @ 2015-08-30 23:53 帕特里克里斯迪安 阅读(521) 评论(0) 推荐(0) 编辑
摘要: 1、计算今年是闰年嘛?判断闰年条件, 满足年份模400为0, 或者模4为0但模100不为0.代码如下:1 x = int(raw_input('please enter a year:'))2 if x % 4 == 0 and x % 100 != 0:3 print 'yes'4 elif ... 阅读全文
posted @ 2015-08-30 23:40 帕特里克里斯迪安 阅读(19496) 评论(0) 推荐(0) 编辑
摘要: 今天看到了http://www.pythondoc.com/pythontutorial27/datastructures.html#tut-tuples的5.1.4,里面有一段:?123>>>freshfruit=['banana','loganberry','passionfruit']>>>[... 阅读全文
posted @ 2015-08-30 19:10 帕特里克里斯迪安 阅读(1534) 评论(0) 推荐(0) 编辑
摘要: 123456789#-*-coding:utf-8-*-importsocketprint"Creatingsocket"s=socket.socket(socket.AF_INET,socket.SOCK_STREAM)print"Done!"print"Connectingtoremotehos... 阅读全文
posted @ 2015-08-30 19:08 帕特里克里斯迪安 阅读(1358) 评论(0) 推荐(0) 编辑
摘要: 原文链接:http://www.oschina.net/question/89964_62779想要弄懂 Python 的错误信息的含义可能有点复杂。这里列出了常见的的一些让你程序 crash 的运行时错误。1)忘记在if,elif,else,for,while,class,def声明末尾添加 :(... 阅读全文
posted @ 2015-08-30 14:09 帕特里克里斯迪安 阅读(1427) 评论(0) 推荐(0) 编辑
摘要: 1 # -*- coding: utf-8 -*- 2 import socket 3 print "Creating socket" 4 s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) 5 print "Done!\n" 6 7 ... 阅读全文
posted @ 2015-08-30 13:50 帕特里克里斯迪安 阅读(163) 评论(0) 推荐(0) 编辑