python string tuple list dict 相互轉換的方法

 

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------

碼農碼代碼之際先賺點小錢,區塊鏈技術應用之-Pi幣 :http://www.javashuo.com/article/p-utwtqoqp-er.html

Pi 軟件安卓版 連接:https://pan.baidu.com/s/1AjWTsROL2ohe24AM55eFGQhtml

或者到官方網站下載:https://minepi.com/#homeiphone

Pi 幣軟件 (iphone)如何下載:http://www.javashuo.com/article/p-toxtfycn-gk.html 區塊鏈

Pi 軟件 用戶註冊:http://www.javashuo.com/article/p-dodwbhsa-ev.html網站

Pi 界面引導(功能介紹):http://www.javashuo.com/article/p-vejbdujf-gg.htmlhtm

Pi 用戶手機驗證:https://www.cnblogs.com/yanxiatingyu/articles/11801772.htmlblog

因爲Pi是邀請制須要邀請碼爲:whlgjjgyy

 

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------ip

dict = {'name': 'Zara', 'age': 7, 'class': 'First'}# 字典轉爲字符串,返回:<type 'str'> {'age': 7, 'name': 'Zara', 'class': 'First'}printtype(str(dict)), str(dict)# 字典能夠轉爲元組,返回:('age', 'name', 'class')printtuple(dict)# 字典能夠轉爲元組,返回:(7, 'Zara', 'First')printtuple(dict.values())# 字典轉爲列表,返回:['age', 'name', 'class']printlist(dict)# 字典轉爲列表printdict.values# 二、元組tup = (1, 2, 3, 4, 5)# 元組轉爲字符串,返回:(1, 2, 3, 4, 5)printtup.__str__()# 元組轉爲列表,返回:[1, 2, 3, 4, 5]printlist(tup)# 元組不能夠轉爲字典# 三、列表nums = [1, 3, 5, 7, 8, 13, 20];# 列表轉爲字符串,返回:[1, 3, 5, 7, 8, 13, 20]printstr(nums)# 列表轉爲元組,返回:(1, 3, 5, 7, 8, 13, 20)printtuple(nums)# 列表不能夠轉爲字典# 四、字符串# 字符串轉爲元組,返回:(1, 2, 3)printtuple(eval("(1,2,3)"))# 字符串轉爲列表,返回:[1, 2, 3]printlist(eval("(1,2,3)"))# 字符串轉爲字典,返回:<type 'dict'>printtype(eval("{'name':'ljq', 'age':24}"))
相關文章
相關標籤/搜索