![](https://img-blog.csdnimg.cn/20201014180756928.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
python字符串操作
songsongv5
No pain , no gain
展开
-
20190427 字符串与字典之间的转换
#1:将字符串:"k:1|k1:2|k2:3|k3:4",字典:{'k':'1', 'k1':'2', 'k2':'3','k3':'4' }s = "k:1|k1:2|k2:3|k3:4"result = {}a = s.split("|")print(a)for i in a: key,value = i.split(":") result[key] = valu...原创 2019-04-27 23:45:31 · 313 阅读 · 0 评论 -
2019-04-18 字符串操作,字符串反转与替换
# *encoding:utf-8 *# author by Vicky 2019-04-18 19:30#把一个单词进行反转输出def word_reverse(word): if isinstance(word,str): result='' for i in range(len(word)): result+=wor...原创 2019-04-18 19:49:16 · 301 阅读 · 0 评论 -
2019-04-20 python3 字符串转换为字典
# -*- encoding:utf-8'''author: Vicky 2019-04-20 08:00'''import json#把下列字符串转换成 json 格式str_info='{"name": "nock", "age": 18}'print(json.loads(str_info))# 把字符下列字符串转换成字典: content='K:1|J:2|L:3|M:...原创 2019-04-20 08:45:53 · 477 阅读 · 0 评论 -
2019-05-17 my_split
from itertools import productdef find_twelve(list1, list2, list3): for num1, num2, num3 in product(list1, list2, list3): if num1 + num2 + num3 == 12: return num1, num2, num3...原创 2019-05-18 01:17:41 · 89 阅读 · 0 评论