a = 2.4440
b = 5.1230
c = 10
print (round(c))
print(a/b)
print (round((a/b),2))
>>num = 3.14j
>>type(num)
<type 'complex'>
整數
a = "12478python"
print (dir(a))
常用的有:
a = "12478python"
print(a.find("python"))
>>5
a = "12478python"
print(a.find("java"))
>> -1
replace 替換字符串
a = "12478python"
print(a.replace("python","java"))
>>12478java
a = "www.vfx.ttd.com"
print(a.split('.'))
>>['www', 'vfx', 'ttd', 'com']
分割次數3次a = "www.vfx.ttd.com.ffd"
print(a.split('.',3))
>>['www', 'vfx', 'ttd', 'com.ffd']
s =" kk henrenzhen"
print (s.strip())
經常使用lstrip去掉左邊的空格,rstrip去掉右邊空格name = "zhoukaivfx"
print ("hello" + name)
print ("hello %s") %name
print ('hello {0}').format(name)
輸出都一樣的。