首页
学习
活动
专区
圈层
工具
发布
    • 综合排序
    • 最热优先
    • 最新优先
    时间不限
  • 来自专栏侯哥的Python分享

    python基础-函数(9)

    如果在开发程序时,需要某块代码多次,但是为了提高编写的效率以及代码的重用,所以把具有独立功能的代码块组织为一个小模块,这就是函数 函数的语法格式: def 函数名(): 函数的功能代码 注意:python 不像其他编程语言使用{}控制作用域,python严格使用缩进控制作用域,所以在python中使用,函数要严格的控制缩进。 定义一个具有两个形式参数的函数 def sum(a,b):#a,b就是形参 result = a+b print(result) #sum()函数的调用 sum(4,5)#4,5就是真实参数 运行结果为:9 def sum(a,b): result = a+b return result#result就是程序要返回出去的值 res = sum(4,5) print(res) 运行结果为:9

    65330发布于 2019-09-11
  • 来自专栏Python基础、进阶与实战

    Python基础-9

    9. 类 类中的概念比较多,初学者掌握面向对象、定义和使用类、单继承、类变量和实例变量即可。迭代器和生成器是Python中迭代利器,推荐掌握。 ---- 面向对象有一些特定的术语,如类、方法、数据成员等,Python3 面向对象 | 菜鸟教程 (runoob.com)。可以搜索面向对象等关键字找到这些概念。 9.3.2 多继承 Python 也支持多重继承。但是用的很少,而且有可能造成名称混乱,不推荐。 初学者可以跳过9.3.2多继承这部分。 要了解更多细节,请参阅 The Python 2.3 Method Resolution Order | Python.org。 9.4 类变量与实例变量 类中有两种变量:实例变量和类变量。 名称改写:Python通过 名称改写对私有变量提供有限支持。

    59550编辑于 2022-12-06
  • 来自专栏Golang开发

    Python基础(9)——私有化

    例如:__init__ , __ 不要自己发明这样的名字 xx_:单后置下划线,用于避免与Python关键词的冲突 通过name mangling(名字重整(目的就是以防子类意外重写基类的方法或者属性)

    73130发布于 2019-05-28
  • 来自专栏算法工程师的学习日志

    Python基础训练100题-9

    分享一些Python学习题目 实例041:类的方法与变量 实例042:变量作用域 实例043:作用域、类的方法与变量 实例044:矩阵相加 实例045:求和 实例041:类的方法与变量 题目:模仿静态变量的用法 程序分析:python中的变量作用域。 X = [[12,7,3], [4 ,5,6], [7 ,8,9]] Y = [[5,8,1], [6,7,3], [4,5,9]] res=[[0,0,0],

    33730编辑于 2022-07-27
  • 来自专栏嘘、小点声

    python网络爬虫(9)构建基础爬虫思路

    目的意义 基础爬虫分5个模块,使用多个文件相互配合,实现一个相对完善的数据爬取方案,便于以后更完善的爬虫做准备。 main__": spider_man=SpiderMan() spider_man.crawl("https://baike.baidu.com/item/%E7%BD%91%E7%BB%9C information" data['url']=page_url return data URL管理器设计 为了避免重复的URL,使用python 参阅:https://www.runoob.com/python3/python3-set.html 使用old_urls存储已经访问过的网址,使用new_urls存入将要提取的网址。

    94710发布于 2019-07-31
  • 来自专栏技术杂记

    Codis 基础9

    添加 Redis Server Group 准备配置文件 [root@h102 codis]# grep -v "^#" extern/redis-2.8.21/redis.conf | grep -v "^$" > /etc/codis/redis_s.conf [root@h102 codis]# grep -v "^#" extern/redis-2.8.21/redis.conf | grep -v "^$" > /etc/codis/redis2.conf [root@h102 codis

    34820编辑于 2022-03-22
  • 来自专栏技术杂记

    Snort 基础9

    解决方法 : 安装 pcre.x86_64 和 pcre-devel.x86_64 软件包

    37020编辑于 2022-05-03
  • 来自专栏技术杂记

    fio基础9

    randrepeat=boolForrandomIOworkloads,seedthegeneratorinapredictablewaysothatresultsarerepeatableacrossrepetitions.Defaultstotrue.randseed=intSeedtherandomnumbergeneratorsbasedonthisseedvalue,tobeabletocontrolwhatsequenceofoutputisbeinggenerated.Ifnotset,therandomsequencedependsontherandrepeatsetting.fallocate=strWhetherpre-allocationisperformedwhenlayingdownfiles.Acceptedvaluesare:noneDonotpre-allocatespaceposixPre-allocateviaposix_fallocate()keepPre-allocateviafallocate()withFALLOC_FL_KEEP_SIZEset0Backward-compatiblealiasfor'none'1Backward-compatiblealiasfor'posix'Maynotbeavailableonallsupportedplatforms.'keep'isonlyavailableonLinux.IfusingZFSonSolaristhismustbesetto'none'becauseZFSdoesn't support it. Default: 'posix'. fadvise_hint=bool By default, fio will use fadvise() to advise the kernel on what IO patterns it is likely to issue. Sometimes you want to test specific IO patterns without telling the kernel about it, in which case you can disable this option. If set, fio will use POSIX_FADV_SEQUENTIAL for sequential IO and POSIX_FADV_RANDOM for random IO. fadvise_stream=int Notify the kernel what write stream ID to place these writes under. Only supported on Linux. Note, this option may change going forward. size=int The total size of file io for this job. Fio will run until this many bytes has been transferred, unless runtime is limited by other options (such as 'runtime', for instance, or increased/decreased by 'io_size'). Unless specific nrfiles and filesize options are given, fio will divide this size between the available files specified by the job. If not set, fio will use the full size of the given files or devices. If the files do not exist, size must be given. It is also possible to give size as a percentage between 1 and 100. If size=20% is given, fio will use 20% of the full size of the given files or devices. io_size=int io_limit=int Normally fio operates within the region set by 'size', which means that the 'size' option sets both the region and size of IO to

    69150编辑于 2022-04-24
  • 来自专栏技术杂记

    SQLite 基础9

    分离数据库 无法分离 main 和 temp 数据库 sqlite> .databases seq name file --- --------------- ---------------------------------------------------------- 0 main /usr/local/sqlite3.11/bin/

    23710编辑于 2021-12-01
  • 来自专栏技术杂记

    memcached基础9

    stats查看状态statsSTAT pid 8917STAT uptime 1183STAT time 1442996635STAT version 1.4.24STAT libevent 1.4.13-stableSTAT pointer_size 64STAT rusage_user 0.014997STAT rusage_system 0.105983STAT curr_connections 12STAT total_connections 14STAT connection_structures

    21110编辑于 2022-06-26
  • 来自专栏技术杂记

    Logstash 基础9

    打开本地的 tcp udp 5000端口 标记类型为 syslog filter中作判断如果类型是 syslog 拆分解析信息 添加 received_at received_from 字段 使用 syslog_pri { } 来处理 定义 syslog_timestamp 的格式 输出到ES 以 rubydebug 的格式输出到终端 启动 Logstash [root@h102 etc]# /opt/logstash/bin/logstash -f logstash-syslog.conf Setti

    27410编辑于 2022-02-10
  • 来自专栏技术杂记

    etcd 基础9

    刷新目录过期时间 [root@docker ~]# date +%s ;curl http://127.0.0.1:2379/v2/keys/testdir -XPUT -d ttl=10 -d dir=true 1454394195 {"action":"set","node":{"key":"/testdir","dir":true,"expiration":"2016-02-02T06:23:25.962070512Z","ttl":10,"modifiedIndex":85,"createdInde

    25310编辑于 2022-01-20
  • 来自专栏技术杂记

    RabbitMQ基础9

    日志信息 =INFO REPORT==== 23-Oct-2015::16:52:50 === Starting RabbitMQ 3.5.6 on Erlang R14B04 Copyright (C) 2007-2015 Pivotal Software, Inc. Licensed under the MPL. See http://www.rabbitmq.com/ =INFO REPORT==== 23-Oct-2015::16:52:50 === node : rabbi

    31820编辑于 2022-05-04
  • 来自专栏技术杂记

    Tengine基础9

    upstream 是nginx 负载均衡的主要模块,它提供了一个简单方法来轮询后端的服务器

    44120编辑于 2022-05-03
  • 来自专栏技术杂记

    UnrealIRCd 基础9

    error: /root/unrealircd/conf/unrealircd.conf:378: set::cloak-keys: (key 2) Keys should be mixed a-zA-Z0-9, error: /root/unrealircd/conf/unrealircd.conf:379: set::cloak-keys: (key 3) Keys should be mixed a-zA-Z0-9, IRCd configuration failed to pass testing 分别为: 1.要求修改操作员角色的用户名和密码 2.cloak-keys 必须得相互不一样,并且由 a-zA-Z0-9

    42620编辑于 2021-11-29
  • 来自专栏技术杂记

    nginx基础9

    启动 查看配置 [root@h102 conf]# grep -v "#" /usr/local/nginx/conf/nginx.conf | grep -v "^$" worker_processes 1; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; sendfile on;

    18910编辑于 2022-05-12
  • 来自专栏技术杂记

    ZooKeeper 基础9

    redo 再次执行之前命令 Tip: 历史命令的保持是在当前会话中,不论此时是否已经成功连接服务 [zk: localhost:2181(CONNECTED) 20] history 10 - ls 11 - ls / 12 - create /test test 13 - get /test 14 - ls / 15 - close 16 - ls / 17 - connect localhost:2181 18 - ls / 19 - help 20 - history [zk: localhos

    31520编辑于 2022-03-25
  • 来自专栏技术杂记

    HAproxy 基础9

    启动haproxy [root@h102 ~]# /usr/local/haproxy/sbin/haproxy -f /etc/haproxy/transparent_proxy.cfg ... ... ... ---------- [root@h102 ~]# netstat -ant | grep 1234 tcp 0 0 0.0.0.0:1234 0.0.0.0:* LISTEN [root@h1

    23910编辑于 2022-01-19
  • 来自专栏技术杂记

    Consul 基础9

    我们还可以使用 DNS API 结合 tag 来过滤服务 [root@h104 ~]# dig @127.0.0.1 -p 8600 rails.web.service.consul ; <<>> DiG 9.9.4-RedHat-9.9.4-29.el7_2.1 <<>> @127.0.0.1 -p 8600 rails.web.service.consul ; (1 server found) ;; global options: +cmd ;; Got answer: ;; ->>HEADER<

    38110编辑于 2021-12-01
  • 来自专栏技术杂记

    Docker 基础9

    可见 docker.service 是依赖于 docker.socket 的,但是并不必要开启

    32620编辑于 2022-02-09
领券