1.
python里面没有对变量“++”的操作,例如: “x++”
2.
用关键字“True”和“False”来表示bool特征,例如:
# -*- coding: utf-8 -*-
"""
Python Version: 3.5
Created on Sun May 7 22:27:34 2017
E-mail: Eric2014_Lv@sjtu.edu.cn
@author: DidiLv
"""
import numpy as np
t = True
f = False
print(type(t),type(f))
输出:
<class 'bool'> <class 'bool'>
3.
python numpy里面没有“||”和“&&”符号,取而代之的为
# -*- coding: utf-8 -*-
"""
Python Version: 3.5
Created on Sun May 7 22:27:34 2017
E-mail: Eric2014_Lv@sjtu.edu.cn
@author: DidiLv
"""
import numpy as np
t = True
f = False
# print(type(t),type(f))
print(t and f)
print(t or f)
print(t != f)
输出为:
False
True
True
4.
# -*- coding: utf-8 -*-
"""
Python Version: 3.5
Created on Sun May 7 22:38:38 2017
E-mail: Eric2014_Lv@sjtu.edu.cn
@author: DidiLv
"""
hello = "hello"
world = "world"
print(hello)
print(hello + " " + world)
print(len(world))
hw12 = "%s %s %d" %(hello, world, 12)
print(hw12)
print("%s, %d" %(hello, 12))
输出:
hello
hello world
5
hello world 12
hello, 12
强力支撑的string功能:注意的是在print语句里“%”是取地址符,然后取地址前不能随便加符号,空格即可
5.
# -*- coding: utf-8 -*-
"""
Python Version: 3.5
Created on Sun May 7 22:48:28 2017
E-mail: Eric2014_Lv@sjtu.edu.cn
@author: DidiLv
"""
s = "hello"
S = "HELLO"
print(s.capitalize())
print(s.upper())
print(S.lower())
print(s.rjust(17))
print(len(s.rjust(17)))
print(S.center(15))
print(S.replace("He", s)) # 注意看字符串中没有相应的替换字符时,输出原有字符串
print(S.replace("HE", s))
print(S.lower().rjust(20).strip()) #strip是删减的意思,这里是删减空格
输出:
Hello
HELLO
hello
hello
17
HELLO
HELLO
helloLLO
hello