这里只是记录个人学习轨迹,体会,无它!详细说明可能以后会补上!
在IDLE中编辑代码如下:
1、代码实例1:
1
2 3 4 5 6 7 8 9 10 11 |
# -*- coding: utf-8 -*- #!/usr/bin/python # FileName: HelloWorld.py from bottle import route, run @route( '/ttt') def hello(): return "Welcome to the Bottle World of Python!" run(host= 'localhost', port= 8080, debug= True) |
按F5或者Run->Run module选项可以得到如下信息:
在浏览器中输入:http://localhost:8080/ttt
则会显示如下:
2、代码实例2:
为了使程序更加易读且避免名称的冲突,导入模块(module)是我们应该尽量避免from...import...而使用import语句。如下:
1
2 3 4 5 6 |
import bottle
@bottle.route( '/') def hello(): return "Welcome to the Bottle World of Python!" bottle.run(host= 'localhost', port= 8080, debug= True) |
在浏览器中输入:http://localhost:8080 (注意没有"/ttt") 会得到同样的结果。