当前位置: 首页 > news >正文

设计素材网站图片万能识图

设计素材网站图片,万能识图,深圳南山工厂网站建设费用,免费查找资料的网站为了solid个人的python编程习惯,简单整理了部分提醒自己今后要注意的地方。 1.不要使用反斜杠联结行,python会将(, {, [中的内容隐式的连接起来 x (This will build a very long long long long long long long long string) 2.Url 如果很长就放到一行…

为了solid个人的python编程习惯,简单整理了部分提醒自己今后要注意的地方。

1.不要使用反斜杠联结行,python会将(, {, [中的内容隐式的连接起来

x = ('This will build a very long long '

'long long long long long long string')

2.Url 如果很长就放到一行

3.尽量不使用括号

return foo

而不是

return (foo)

4.括号内不要有空格.

Yes: spam(ham[1], {eggs: 2}, [])

5.在二元操作符两边都加上一个空格, 比如赋值(=), 比较(==, <, >, !=, <>, <=, >=, in, not in, is, is not), 布尔(and, or, not).

6.当’=’用于指示关键字参数或默认参数值时, 不要在其两侧使用空格.

Yes: def complex(real, imag=0.0): return magic(r=real, i=imag)

No:def complex(real, imag = 0.0): return magic(r = real, i = imag)

7.注释使用 主要描述做什么 然后 args, returns, raises

"""Fetches rows from a Bigtable.

Retrieves rows pertaining to the given keys from the Table instance

represented by big_table.Silly things may happen if

other_silly_variable is not None.

Args:

big_table: An open Bigtable Table instance.

keys: A sequence of strings representing the key of each table row

to fetch.

other_silly_variable: Another optional variable, that has a much

longer name than the other args, and which does nothing.

Returns:

A dict mapping keys to the corresponding table row data

fetched. Each row is represented as a tuple of strings. For

example:

{'Serak': ('Rigel VII', 'Preparer'),

'Zim': ('Irk', 'Invader'),

'Lrrr': ('Omicron Persei 8', 'Emperor')}

If a key from the keys argument is missing from the dictionary,

then that row was not found in the table.

Raises:

IOError: An error occurred accessing the bigtable.Table object.

"""

pass

8.类注释

类应该在其定义下有一个用于描述该类的文档字符串. 如果你的类有公共属性(Attributes), 那么文档中应该有一个属性(Attributes)段. 并且应该遵守和函数参数相同的格式.

class SampleClass(object):

"""Summary of class here.

Longer class information....

Longer class information....

Attributes:

likes_spam: A boolean indicating if we like SPAM or not.

eggs: An integer count of the eggs we have laid.

"""

def __init__(self, likes_spam=False):

"""Inits SampleClass with blah."""

self.likes_spam = likes_spam

self.eggs = 0

def public_method(self):

"""Performs operation blah."""

9.块注释和行注释

最需要写注释的是代码中那些技巧性的部分. 如果你在下次代码审查 的时候必须解释一下, 那么你应该现在就给它写注释. 对于复杂的操作, 应该在其操作开始前写上若干行注释. 对于不是一目了然的代码, 应在其行尾添加注释.

# We use a weighted dictionary search to find out where i is in

# the array.We extrapolate position based on the largest num

# in the array and the array size and then do binary search to

# get the exact number.

if i & (i-1) == 0:# True if i is 0 or a power of 2.

另一方面, 绝不要描述代码. 假设阅读代码的人比你更懂Python, 他只是不知道你的代码要做什么.

10.类继承

如果一个类不继承自其它类, 就显式的从object继承. 嵌套类也一样.

class SampleClass(object):

pass

class OuterClass(object):

class InnerClass(object):

pass

11.字符串

x = a + b

x = '%s, %s!' % (imperative, expletive)

x = '{}, {}!'.format(imperative, expletive)

x = 'name: %s; score: %d' % (name, n)

x = 'name: {}; score: {}'.format(name, n)

12.单引号,双引号一致性

13.TODO注释

为临时代码使用TODO注释, 它是一种短期解决方案. 不算完美, 但够好了.

TODO注释应该在所有开头处包含”TODO”字符串, 紧跟着是用括号括起来的你的名字, email地址或其它标识符. 然后是一个可选的冒号. 接着必须有一行注释, 解释要做什么.

# TODO(kl@gmail.com): Use a "*" here for string repetition.

# TODO(Zeke) Change this to use relations.

14.每个导入应该独占一行

import os

import sys

http://www.lbrq.cn/news/2492461.html

相关文章:

  • wordpress复制提醒seo推广软件
  • 专业做厂房的网站网站设计公司报价
  • 洛阳微网站建设网站百度权重查询
  • 西安网站建设制作价格数据交换平台
  • 南宁企业网站排名优化市场调研模板
  • 网站建设公司内幕百度极速版下载安装
  • 网站设计实施方案电脑培训机构
  • 南京移动网站设计政府免费培训 面点班
  • 公司建设网站需要去哪报备百度推广总部客服投诉电话
  • 九亭微信网站建设59软文网
  • 党建网站建设课题自助优化排名工具
  • jsp ajax网站开发典型实例pdf整合营销传播的方法包括
  • 旅游网站建设步骤做网络推广一个月的收入
  • 邯郸做网站推广找谁seo博客写作
  • 手机端网站如何做排名靠前营销网站建设免费
  • 江苏城乡住房和城乡建设厅网站百度seo策略
  • 地方门户网站用户seo网站推广优化
  • 服装公司电商网站建设规划seo优化工具有哪些
  • 帝国做的网站怎么上传关键词seo价格
  • 用.net做视频网站的案例会员制营销
  • 让人做网站 需要准备什么条件推广app的方法和策略
  • 永川做网站的公司今日最新重大新闻
  • wordpress主题发布站源码推广平台的方法
  • 网站怎么做才不会被墙企业网站优化哪家好
  • 汽车行业网站建设搜狐新闻手机网
  • 手机网站后台管理系统seo公司推荐
  • 哪家公司建设网站python培训
  • 中国有色金属建设股份有限公司网站seo在线外链
  • 永春网站设计查权重工具
  • 江西头条热点新闻搜索引擎排名优化程序
  • AI大模型前沿:Muyan-TTS开源零样本语音合成技术解析
  • Git Commit 生成与合入 Patch 指南
  • 机器学习特征选择 explanation and illustration of ANOVA
  • Java程序员学从0学AI(六)
  • 智慧水库管理系统中标签工厂的建立方案
  • Golang语言基础—函数调用