码迷,mamicode.com
首页 > 其他好文 > 详细

day05-集合

时间:2018-07-07 23:05:33      阅读:202      评论:0      收藏:0      [点我收藏+]

标签:enc   span   com   datetime   als   orm   dump   lse   time   

 

 

l  = [1,2,3,3,3,44,4,4,1]

print(set(l))

s = set()
s  = {1,2,3,4}


def my(name,sex=): #形式参数
    print(hahaha,name)
    return name

my(111)#实际参数


def read_file(file_name):
    with open(file_name,encoding=utf-8) as f:
        return f.read()

import datetime
def welcome(name):
    msg = 欢迎登录【%s】,今天的日期是 【%s】%(name,datetime.date.today())
    print(msg)
import json
f  = open(a.txt,w,encoding=utf-8)
# res = f.read()
# json.loads(res) #
# json.load(f)  #把json串变成字典
goods  = {
    宝马:11111,
    奔驰:22222
}
print(json.dumps(goods))

# json.dumps(d) #把字典转成json

# json.dump(goods,f,ensure_ascii=False)# json会帮你write一次

msg = 欢迎光临 {name} ,今天的日期是 {today} 

msg = msg.format(name=刘欣雨,today=datetime.datetime.today() )
print(msg)
# sql = ‘insert into my_user value ({id},{name},{addr},{sex},{phone}) ‘
# sql.format(name=‘aaa‘,addr=‘sdfsfd‘,sex=‘xxx‘,id=11)

# sql = ‘insert into {} value {}; ‘.format(‘abc,‘,‘bcd‘)
# print(sql)
# sql=‘insert into my_user value (%s,%s,%s,%s,%s,%s,%s,%s)‘%(id,name,sex,addr,phone,)
# +
# %s

# format_map
d = {name:小黑,sex:不知道}
words =名字 {name}  ,性别 : {sex}.format_map(d)
print(words)

#字符集
        # 只认识2进制 0  1
        # 0 1
    # 阿斯克码表     12  {}

 

day05-集合

标签:enc   span   com   datetime   als   orm   dump   lse   time   

原文地址:https://www.cnblogs.com/Noul/p/9278712.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!