电脑桌面
添加小米粒文库到电脑桌面
安装后可以在桌面快捷访问

使用Python进行socket编程

使用Python进行socket编程_第1页
1/16
使用Python进行socket编程_第2页
2/16
使用Python进行socket编程_第3页
3/16
使用 Python 进行 socket 编程 体验 Python 下面我们先对 Python 是什么建立一个直观印象。 作为一种解释性语言,Python 很容易使用,并且能够快速验证我们的想法和开发原型软件。Python 程序可以作为一个整体进行解释,也可以一行行地解释。 可以在第一次运行 Python 时测试一下下面的 Python 代码,然后一次只输入一行试试。在 Python 启动之后,会显示一个提示符(>>>),可以在这里输入命令。 注意在 Python 中,缩进非常重要,因此代码前面的空格不能忽略: 清单 1. 可以试验的几个 Python 例子 # Open a file, read each line, and print it out for line in open('file.txt'): print line # Create a file and write to it file = open("test.txt", "w") file.write("test line\n") file.close() # Create a small dictionary of names and ages and manipulate family = {'Megan': 13, 'Elise': 8, 'Marc': 6} # results in 8 family['Elise'] # Remove the key/value pair del family['Elise'] # Create a list and a function that doubles its input. Map the # function to each of the elements of the list (creating a new # list as a result). arr = [1, 2, 3, 4, 5] def double(x): return x*x map(double, arr) # Create a class, inherit by another, and then instantiate it and # invoke its methods. class Simple: def __init__(self, name): self.name = name def hello(self): print self.name+" says hi." class Simple2(Simple): def goodbye(self): print self.name+" says goodbye." me = Simple2("Tim") me.hello() me.goodbye() 为什么使用 Python? 我们要学习和使用 Python 的一个原因是它非常流行。Python 用户的数量以及使用 Python 编写的应用程序的不断增长使这种努力是值得的。 在很多开发领域中都可以看到 Python 的踪迹,它被用来构建系统工具,用作程序集成的黏合剂,用来开发 Internet 应用程序和快速开发原型。 Python 与其他脚本语言相比也有一定的优势。它的语法非常简单,概念非常清晰,这使得 Python 非常容易学习。在使用复杂的数据结构(例如列表、词典和元组)时,Python 也非常简单...

1、当您付费下载文档后,您只拥有了使用权限,并不意味着购买了版权,文档只能用于自身使用,不得用于其他商业用途(如 [转卖]进行直接盈利或[编辑后售卖]进行间接盈利)。
2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。
3、如文档内容存在违规,或者侵犯商业秘密、侵犯著作权等,请点击“违规举报”。

碎片内容

使用Python进行socket编程

确认删除?
VIP
微信客服
  • 扫码咨询
会员Q群
  • 会员专属群点击这里加入QQ群
客服邮箱
回到顶部