![](https://img-blog.csdnimg.cn/20201014180756916.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
python
stronglily
这个作者很懒,什么都没留下…
展开
-
python学习之路之基础篇(一)
字母、数字、下划线组成标识符 不能数字开头 区分大小写 单下划线开头代表不能直接访问的类属性,需通过类提供的接口进行访问 双下划线开头代表类的私有成员 双下划线开头和结尾的代表python里特殊方法的专用标识 print(‘hello’); print(‘python’); 多行语句 使用斜杠\将一行的语句分为多行显示 如果语句中含有[]、{}、()不需要使用\多行连接符 单引号、双引号、三引号表...原创 2019-09-09 09:39:35 · 116 阅读 · 0 评论 -
python学习之路之基础篇—循环小游戏
猜拳小游戏 raw_input()把输入的都当作字符串,而input()输入什么类型就是什么类型. import random from pip._vendor.distlib.compat import raw_input while 1: s = int(random.randint(1, 3)) if s == 1: ind = '石头' elif ...原创 2019-09-09 11:08:25 · 1041 阅读 · 0 评论 -
python学习之路之基础篇(二)
函数定义和调用 def printme(str): # 打印任何传入的字符串 print(str) return printme('我要调用用户自定义函数!') # 格式要求 空两行 printme('我要再次调用!') 参数传递 在python中,strings, tuples, 和numbers是不可更改的对象,而 list,dict 等则是可以修改的对象。 ...原创 2019-09-12 10:53:03 · 142 阅读 · 0 评论 -
python学习之路之基础篇(三)
正则表达式 re.M和re.I为正则表达式修饰符的可选标志 re.I表示使匹配对大小写不敏感,re.M表示多行匹配,影响^(字符串开头)和$(结尾) import re line = 'cats are smarter than dogs' matchObj = re.match(r'(.*) are (.*?).*', line, re.M | re.I) if matchObj: p...原创 2019-09-12 17:42:59 · 101 阅读 · 0 评论 -
python学习之路之基础篇(四)
数据库操作 import pymysql # 数据库连接 db = pymysql.connect('localhost', 'root', 'root', 'secondhandmarket') # 创建一个游标对象 cursor = db.cursor() # 使用execute()方法执行sql查询 cursor.execute('select version()') # 使用fetcho...原创 2019-09-16 15:52:21 · 103 阅读 · 0 评论