首页 > 学院 > 开发设计 > 正文

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

2019-11-14 17:16:08
字体:
来源:转载
供稿:网友

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


发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表