首页 > 编程语言 > 详细

Python 基础教程中的问题及解决方案(1)

时间:2015-04-18 11:27:32      阅读:484      评论:0      收藏:0      [点我收藏+]

1、 在ubuntu中,调用终端时如:

     f = open(‘/home/theone/test_input.txt‘, ‘r‘) 中的txt格式文本不能加后缀

    正确的应为:  f = open(‘/home/theone/test_input‘, ‘r‘) 

    同样的,生成html时:$ python simple_markup.py < test_input.txt > test_output.html

    也应为:$ python simple_markup.py < test_input > test_output.html

 

2、若忘记保存的.py文件应放在何处时

    在IDLE中输入 

    >>>import sys

    >>>sys.path

    就得到了保存的可直接运行的目录

 

ps:

if判断条件还可以简写,比如写:

    if x:    

        print ‘True‘

只要x是非零数值、非空字符串、非空list等,就判断为True,否则为False

Python 基础教程中的问题及解决方案(1)

原文:http://www.cnblogs.com/Mellcap/p/4436998.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!