import re class Retest: def __init__(self,string,path): self.string = string self.path = path def retest(self): res = re.search(self.string,self.path,flags=0).group() # res.group() print res return if __name__ == '__main__': a = 'helloworld' b = 'he(…
Python 字符串——巧取值和列表——巧取值 对比 1.字符串取值实例: samp_string = "Whatever you are, be a good one." for i in samp_string: print(i) ,len(samp_string)-,): print(samp_string[i]+samp_string[i+]) print('A=',ord("A")) print()) print('桃:',ord("桃"…
数字 写在最前,必须要会的:int() 整型 Python3里无论数字多长都用int表示,Python2里有int和Long表示,Long表示长整型 有关数字的常用方法,方法调用后面都必须带括号() int():将字符串转换为整型,且字符串内容只能是数字 a = " b = "123a" c = int(a) d = int(b) # ValueError: invalid literal for int() with base 10: '123a' print(type(c…