随笔分类 -  Python

摘要:类: 属性--数据 方法--函数 [root@k8s-master python3-test]# cat 9.py #! /usr/bin/python3 #encoding=utf-8 class Dog: #类名第一个字母大写 def bark(self): 函数括号中要加个self print 阅读全文
posted @ 2021-11-08 00:55 闲云野鹤cs 阅读(95) 评论(0) 推荐(0)
摘要:1、计算字符串最后一个单词的长度,单词以空格隔开 #!/usr/bin/python a=input().strip() a=a[-1::-1] count=0 for i in a: if i!=" ": count+=1 else: break print(count) a=input().st 阅读全文
posted @ 2020-12-13 17:21 闲云野鹤cs 阅读(424) 评论(0) 推荐(0)
摘要:1、requests库 https://requests.readthedocs.io/en/master/ 安装requests库,pip install requests python2.7.5 安装pip 1 先安装setuptools liunx : wget https://files.p 阅读全文
posted @ 2020-11-09 16:15 闲云野鹤cs 阅读(17) 评论(0) 推荐(0)
摘要:1、print打印变量 若打印中文,在文件开头加入 # -*- coding: UTF-8 -*- 或者 # coding=utf-8 cat >> 1.py << 'EOF'#!/usr/bin/python # -*- coding: UTF-8 -*- counter = 100 # 赋值整型 阅读全文
posted @ 2020-11-03 11:34 闲云野鹤cs 阅读(152) 评论(0) 推荐(0)
摘要:1、下载链接 https://www.python.org/downloads/windows/ 进入下载页面,我们选择可执行下载 代码编辑器pycharm:https://www.jetbrains.com/pycharm/download/#section=windows 用社区版免费 2、开始 阅读全文
posted @ 2020-09-26 00:33 闲云野鹤cs 阅读(204) 评论(0) 推荐(0)