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:
新聞熱點
疑難解答