a page one day 2

last time i run a python in shell . so are  there  any  other techonicals  to  do . the key is yes , for sure . remmenber the editor i referfed to . they are ok .

 i will use it as a new way to run a python script that  also shows the  hello world .

chrysanthemumwolf@chrysanthemumwolf-laptop:~$ vim helloworld.py
chrysanthemumwolf@chrysanthemumwolf-laptop:~$ cat helloworld.py
#!usr/bin/python
#filename :helloworld.py

print 'hello world'
chrysanthemumwolf@chrysanthemumwolf-laptop:~$ python helloworld.py
hello world
chrysanthemumwolf@chrysanthemumwolf-laptop:~$

note: the notation in the first line of the small script is telling the linux(your os)  that this is programm should be run with this interpreter when you x it . and other # is just the comment  like in c/c++.

 

following it is the constant i learn .

python has four number type  : integer, long integer, floating point , and complex number. and this is kinda different from c/c++.

and it doesn`t have a char but a string type to hold a constant .

we can use string like that

print 'i am wolf'

or print "i am wolf"

or print  '''  i am wolf '''

these are the results:

>>> print 'i am wolf'
i am wolf
>>> print "i am wolf"
i am wolf
>>> print '''i am wolf'''
i am wolf
>>> whereas what`s the differece betweeen (among)the single quotes , double quotes ,and triple quotes.

i will give some instance to explore it .

>>> print 'what's your name'
  File "<stdin>", line 1
    print 'what's your name'
                ^
SyntaxError: invalid syntax
>>> print 'what/'s your name'
what's your name
>>> print ''

>>> print "what's your name"
what's your name
>>> print '''what's your name'''
what's your name
 

i want to explain it simple not complicated like the books written by the c++ giant.

the fuction of them are the same . what makes them different is that we cannot use the same notations in the string . ihe interpretor will be get confused by that .and it cannot match them one by one . so the use of "" & ''' ''' is the same.

 

one of the necessary part is if you write a long command or statement ,and do not want to seperate  it into two lines ,what wolud you gonna do . we should still use the escape sequence  /  that`s ok. 

good luck . 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值