笨办法学Python ex01

第一个程序


  • 输入:
print "Hello Again"
print "I like typing this." 
print "This is fun."
print "Yay! Printing."
print "I'd much rather you 'not'."
print "I'd much rather you 'not'."
print 'I "said" do not touch this.'
  • 运行:

    笨办法学Python ex01_第1张图片

遇到的问题:

运行过程中,在cmd换目录:
换盘> d: 回车换
目录> cd mybook 回车


附加题


  • 1、让你的脚本多打印一行
print "Hello World!"
print "Hello Again"
print "I like typing this." 
print "This is fun."
print "Yay! Printing."
print "I'd much rather you 'not'."
print "I'd much rather you 'not'."
print 'I "said" do not touch this.'
print u"我来自中国!"
笨办法学Python ex01_第2张图片

遇到的问题:

使用python自带的文本编辑器,设置好了utf-8,且头行标注了格式,在cmd运行文件的时候还是出现中文的乱码。
百度这个问题,有个回答:print u"我来自中国!",前面加了u,这样就能正常显示了

  • 2、让你的脚本只打印一行
    只需要在代码前加注释符号“#”即可
  • 3、在某行的起始位置放一个#(#)符号。它的作用是什么?
    能够将该行代码转为注释,运行的时候会跳过注释

你可能感兴趣的:(笨办法学Python ex01)