[{"createTime":1735734952000,"id":1,"img":"hwy_ms_500_252.jpeg","link":"https://activity.huaweicloud.com/cps.html?fromacct=261f35b6-af54-4511-a2ca-910fa15905d1&utm_source=V1g3MDY4NTY=&utm_medium=cps&utm_campaign=201905","name":"华为云秒杀","status":9,"txt":"华为云38元秒杀","type":1,"updateTime":1735747411000,"userId":3},{"createTime":1736173885000,"id":2,"img":"txy_480_300.png","link":"https://cloud.tencent.com/act/cps/redirect?redirect=1077&cps_key=edb15096bfff75effaaa8c8bb66138bd&from=console","name":"腾讯云秒杀","status":9,"txt":"腾讯云限量秒杀","type":1,"updateTime":1736173885000,"userId":3},{"createTime":1736177492000,"id":3,"img":"aly_251_140.png","link":"https://www.aliyun.com/minisite/goods?userCode=pwp8kmv3","memo":"","name":"阿里云","status":9,"txt":"阿里云2折起","type":1,"updateTime":1736177492000,"userId":3},{"createTime":1735660800000,"id":4,"img":"vultr_560_300.png","link":"https://www.vultr.com/?ref=9603742-8H","name":"Vultr","status":9,"txt":"Vultr送$100","type":1,"updateTime":1735660800000,"userId":3},{"createTime":1735660800000,"id":5,"img":"jdy_663_320.jpg","link":"https://3.cn/2ay1-e5t","name":"京东云","status":9,"txt":"京东云特惠专区","type":1,"updateTime":1735660800000,"userId":3},{"createTime":1735660800000,"id":6,"img":"new_ads.png","link":"https://www.iodraw.com/ads","name":"发布广告","status":9,"txt":"发布广告","type":1,"updateTime":1735660800000,"userId":3},{"createTime":1735660800000,"id":7,"img":"yun_910_50.png","link":"https://activity.huaweicloud.com/discount_area_v5/index.html?fromacct=261f35b6-af54-4511-a2ca-910fa15905d1&utm_source=aXhpYW95YW5nOA===&utm_medium=cps&utm_campaign=201905","name":"底部","status":9,"txt":"高性能云服务器2折起","type":2,"updateTime":1735660800000,"userId":3}]
1.Python是这样一种语言
* Python是一门跨平台、开源、免费的解释型高级动态编程语言。
* Python支持命令式编程、函数式编程,完全支持面向对象程序设计,拥有大量扩展库。
* 胶水语言:可以把多种不同语言编写的程序融合到一起实现无缝拼接,更好地发挥不同语言和工具的优势,满足不同应用领域的需求。
举两个例子:
2.Python编程规范与优化建议
(1)缩进
* 类定义、函数定义、选择结构、循环结构、with块,行尾的冒号表示缩进的开始。
* python程序是依靠代码块的缩进来体现代码之间的逻辑关系的,缩进结束就表示一个代码块结束了。
* 同一个级别的代码块的缩进量必须相同。
* 一般而言,以4个空格为基本缩进单位。
(2)每个import语句只导入一个模块,最好按标准库、扩展库、自定义库的顺序依次导入。
(3)最好在每个类、函数定义和一段完整的功能代码之后增加一个空行,在运算符两侧各增加一个空格,逗号后面增加一个空格。
(4)尽量不要写过长的语句。如果语句过长,可以考虑拆分成多个短一些的语句,以保证代码具有较好的可读性。如果语句确实太长而超过屏幕宽度,最好使用续行符(line
continuation character)“\”,或者使用圆括号将多行代码括起来表示是一条语句。
(5)虽然Python运算符有明确的优先级,但对于复杂的表达式建议在适当的位置使用括号使得各种运算的隶属关系和顺序更加明确、清晰。
(6)注释
* 以符号#开始,表示本行#之后的内容为注释。
* 包含在一对三引号’’’…’’'或"""…"""之间且不属于任何语句的内容将被解释器认为是注释。