其他分享
首页 > 其他分享> > exercise

exercise

作者:互联网

 

 

json.dumps(data,ensure_ascii=False,indent=4,sort_keys=True,skipkeys=True,separators=(',',': '))

try:
    b(1,0)
except Exception as e:
    logging.exception(sys.exc_info())
    # logging.error(e,exc_info=True)  # 额外使用exc_info=True参数,打印traceback信息
    
'{1!s:} {0!r:}'.format('uiop','vbnm')

names={'name':'Kevin','name2':'Tom'}
print('hello {names[name]}  i am {names[name2]}'.format(names=names))
name name2不带引号

args=['lu']
kwargs={'n1':'uiopo','n2':'vbnm'}
print('{n1} {} {n2}'.format(*args,**kwargs))
print('{:0>5}'.format(5))
print('{:x<5}'.format(5))
print('{:x^6}'.format(5))
print('{{ui {}}}'.format('uiop'))
b='ui {1:} {0:}'.format
print(b,type(b))
print(b('uiop','vbnm'))
import datetime
print('{:%Y %j %z %X}'.format(datetime.datetime.today()))
print('uiop {1:*>{0:}}'.format(10,'jkl'))
print(ascii('发明我'))
print('\u53d1\u660e\u6211')
print('{!s}'.format('发明我'))
print('{!r}'.format('发明我'))
print('{!a}'.format('发明我'))
print('{:X^+30.2f}'.format(-11.8888))

    def __getattribute__(self,item):
        return super(Employee,self).__getattribute__(item)
        return getattr(self,item)
    def __getattr__(self,item):
        return None
    
    def __getitem__(self,item):
        return super(Employee,self).__getattribute__(item)

 

标签:__,format,self,item,names,print,exercise
来源: https://www.cnblogs.com/dissipate/p/14695125.html