zoukankan      html  css  js  c++  java
  • Lesson one of python

    Test1:Use the powershell to output the contents

    1 print "Hello World!"
    2 print "Hello Again"
    3 print "I like typing this."
    4 print "This is fun."
    5 print 'Yay! Printing.'
    6 print "I'd much rather you 'not'."
    7 print 'I "said" do not touch this.'

    首先,我们要把上面这段代码通过文本编辑器(我用的是gedit,当然Windows自带的记事本也行)保存成.py的格式。

    接着我们打开powershell,利用cd的命令打开你所保存的.py文件的文件夹,只有这样才能利用python来跑这段脚本。

    最后我们在光标处输入python (文件名).py再回车即可运行以上python脚步了。

    Running result:

    PS C:UsersAdmindesktop> python ex1.py
    Hello World!
    Hello Again
    I like typing this.
    This is fun.
    Yay! Printing.
    I'd much rather you 'not'.
    I "said" do not touch this.

    Other topic:

    1. 让你的脚本再多打印一行。
    2. 让你的脚本只打印一行。
    3. 在一行的起始位置放一个 ‘#’ (octothorpe) 符号。它的作用是什么?自己研究一下。

    Let's solve the problems!

    1:可以在当前的.py文件中修改源代码在代码末尾加入一行print “             ”,这样running的result就会变成多打印了一行(总觉得不应该这么傻瓜样的操作,看以后深入学习了再来修改这里吧)

    2:只用一个print

    3:这个我们可以自己加的试试running一下。结果出来我们很容易知道#号的功能是注释,在哪一行前面加上#,这一行的内容将不会被打印出来

    至此,我们的习题一就结束了。

  • 相关阅读:
    【Redis】简介与安装
    【JAVA】 Java 连接池的工作原理
    【异常】ORA-01536: space quota exceeded for tablespace
    【Oracle】Oracle 序列步长问题
    【ORACLE】常用脚本
    【ORACLE】特殊的NULL
    【JAVA】Runtime
    【JAVA】Calendar
    出现脚本错误或者未正确调用 Page()
    小程序出现 “2 not found” 解决方案
  • 原文地址:https://www.cnblogs.com/learnC/p/5546137.html
Copyright © 2011-2022 走看看