Python边学边用
来源:互联网 发布:手机测经纬度软件 编辑:程序博客网 时间:2024/06/06 11:02
由于要对10x10的节点设置静态路由,如果手动写真的太费事了。。。考虑使用编程实现。由于一直想学Python,就借机边学边用吧~~
Python:是一种面向对象、直译式计算机编程语言。它包含了一组完善而且容易理解的标准库,能够轻松完成很多常见的任务。它的语法简捷和清晰,尽量使用无异义的英语单词,与其它大多数程序设计语言使用大括号不一样,它使用缩进来定义语句块。
Python开发者的哲学是“用一种方法,最好是只有一种方法来做一件事”。
相对于C/C++来说,Python真的好简单!最终实现代码如下
#create static routeM = 20 #rowN = 20 #columnstr = "169.0.0."file = open( 'D:\document\Desktop\pftsp_400.routes-static', 'w' ) for n in range(1,N+1,1):for m in range(1,M+1,1):x = m + (n-1)*Mif (n > 1): #m + (n-2)*Mstr1="%d %s%d %s%d\n" % (x,str,x-M,str,x-M)file.write(str1)if (m > 1): #m-1 + (n-1)*Mstr1="%d %s%d %s%d\n" % (x,str,x-1,str,x-1)file.write(str1)if (m < M): #m+1 + (n-1)*Mstr1="%d %s%d %s%d\n" % (x,str,x+1,str,x+1)file.write(str1)if (n < N): #m + n*Mstr1="%d %s%d %s%d\n" % (x,str,x+M,str,x+M)file.write(str1)file.write("\n\n")file.close()
0 0
- Python边学边用
- Python边学边用 - Python based Deeplearning Framework
- 边学边用python-searchs.py
- Python
- Python
- Python
- python
- Python
- PYTHON
- Python
- Python
- Python
- Python
- Python
- Python
- Python
- Python
- Python
- UVa 11488 - Hyper Prefix Sets
- Java颜色选择器
- 同余定理
- Codeforce E. Lucky Queries 线段树实践
- nginx源码分析--使用GDB调试
- Python边学边用
- 浅显理解 Python 闭包
- 修改 mysql 密码
- 我的软考之路(九)——总结篇
- 第二学期第十二周项目1--长颈鹿类对动物类的继承
- 第13周 点圆关系
- C++箭头(->)运算符的重载
- 关于百度地图、腾讯地图、高德地图、谷歌地图、天地图的那点事儿
- MessageBox 的一些用法