Python的一些特殊用法总结
生活随笔
收集整理的這篇文章主要介紹了
Python的一些特殊用法总结
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
格式化打印輸出
values=input(">>>") l=values.split(",") t=tuple(l) print(f"List of values : {l}") print(f"Tuple of values : {t}") x = {'name':"xiong","age":26} print(f"{x}")''' >>>12,56,48,98,36,22 List of values : ['12', '56', '48', '98', '36', '22'] Tuple of values : ('12', '56', '48', '98', '36', '22') {'name': 'xiong', 'age': 26} '''一行代碼實現的for循環
#Python學習交流QQ群:778463939 n=int(input(">>>")) d={x:x*x for x in range(1,n+1)} print(d)""" >>>8 {1: 1, 2: 4, 3: 9, 4: 16, 5: 25, 6: 36, 7: 49, 8: 64} """ 與50位技術專家面對面20年技術見證,附贈技術全景圖總結
以上是生活随笔為你收集整理的Python的一些特殊用法总结的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: python字典函数fromkeys()
- 下一篇: Python动态绑定属性和方法