#!/usr/bin/env python
# -*- coding:utf-8 -*-
print '%d'%520
print u'ascii码的65代表:%s'%(chr(65)) #内置方法执行的结果
print 'ascii码的65代表:%c'%(65) #%c 代表把它格式化为ascii
# print '1+1=%s'%(1+1)
# print '100*245=%d'%(100*245)
# print ord('A')
# print chr(65)
demo2.py
#!/usr/bin/env python
# -*- coding:utf-8 -*-
# print 'my name is %s'%'list'
# print 'my name is :{},age:{}'.format("list",20)
# print "::".format('list','rose','xiaoquan')
# print ''.format(4,5,6,name='list') #只要是多个 就一定要用逗号分隔开
# print ':'.format(name='list',age=20)
#name,age ='list',20
#print ':'.format(name='rose',age=20)
#print ''.format{'name':'list','age':20}
#print '%(name)s:%(age)s'%{'name':'list','age':20}
#print ':'.format({'name':'list','age':20})
# a ={'name':'list'}
# b ={'age':20}
# print '{[name]}:{[age]}'.format(a,b)
# print ':'.format({'name':'list','age':20},{'name':'rose','age':70})
#print '{[name]}'.format(dict(name='list')) #字典
print dict(name='list')
demo3.py
# print ':'.format(name,age)
# print '{}:{}'.format(name,age)
#!/usr/bin/env python
# -*- coding:utf-8 -*-
# name,age ='lsit',20
# print '{} is {} years old.'.format(name,age)
# print '{} is a girl'.format('小芳')
# print ' is years old.'.format(name='小芳',age=18)
# print 'open file name is :'.format(open('abc.txt','w')) #目前不要理他 open是用于打开文件对象 name是文件对象的属性 但是方法也是可以
print 'my name is : ok'.format('list') #指定一个宽度
领取专属 10元无门槛券
私享最新 技术干货