摘要: #-*-coding:utf-8-*- ''' 函数复习 ''' def f(): return 'bowen' print(2+3) # 事实上python中会调用内部的函数,相当于add() print(f()) def wahaha(*args): print(args) wahaha(1,2,3) l = [1,2,3] wahaha(*l) ''' 默认参数的陷阱 ... 阅读全文
posted @ 2019-01-08 23:33 sunnybowen 阅读(184) 评论(0) 推荐(0) 编辑
摘要: #-*-coding:utf-8-*- ''' 实现一个加法计数器 如5+7+9,进行分割再进行计算,将结果存入字典中dic = {"":"} ''' dic = {} content = input("请输入内容:").strip() content_list = content.split('+') #print(content_list) sum = 0 for i in cont... 阅读全文
posted @ 2019-01-06 23:17 sunnybowen 阅读(784) 评论(0) 推荐(0) 编辑
摘要: #-*-coding:utf-8-*- ''' 统计用户输入内容,索引为奇数,并且对于的索引的是数字的个数 ''' count = 0 content = input(">>>") for i in range(len(content)): if i%2 == 1 and content[i].isdigit(): content +=1 print(count) ... 阅读全文
posted @ 2019-01-06 23:16 sunnybowen 阅读(609) 评论(0) 推荐(0) 编辑
摘要: #-*-coding:utf-8-*- ''' 从100打印到0 ''' for i in range(100,-1,-1): print(i) 阅读全文
posted @ 2019-01-06 23:15 sunnybowen 阅读(705) 评论(0) 推荐(0) 编辑
摘要: #-*-coding:utf-8-*- ''' join()方法,注意列表元素要是str类型的,不能是int,否则会报错 ''' lis = ['q','qw','1'] s = '*'.join(lis) print(s) 阅读全文
posted @ 2019-01-06 22:01 sunnybowen 阅读(175) 评论(0) 推荐(0) 编辑
摘要: 1 无参函数 2 无返回值的情况 3 一个返回值 4 返回多个返回值 5 解包 6 带参数的函数 7 函数调用 阅读全文
posted @ 2019-01-06 16:38 sunnybowen 阅读(170) 评论(0) 推荐(0) 编辑
摘要: #-*-coding:utf-8-*- ''' 三次登录再次优化,利用文件操作这个程序注意:1、把用户名和密码以w方式写进去时候,是怎么实现换行的? format的用法 2、把文件读出来的时候,是怎么读的,是怎么去掉换行符的? 循环放到列表里 ''' lis= [] username = input('username:') password = input('passw... 阅读全文
posted @ 2019-01-05 23:50 sunnybowen 阅读(130) 评论(0) 推荐(0) 编辑
摘要: 程序内部的逻辑重要,还有这个程序涉及到的知识点 阅读全文
posted @ 2019-01-02 20:25 sunnybowen 阅读(266) 评论(0) 推荐(0) 编辑
摘要: 这个程序本身没什么,但内部的逻辑还是值得学习的 阅读全文
posted @ 2019-01-02 18:49 sunnybowen 阅读(174) 评论(0) 推荐(0) 编辑
摘要: #-*-coding:utf-8-*- ''' 有多少个数(连续),输入字符串(只有字母和数字) ''' info = input(">>>") for i in info: # 判断是不是字母 if i.isalpha(): info = info.replace(i,' ') l = info.split() print(l) print(len(l)) ... 阅读全文
posted @ 2019-01-02 15:43 sunnybowen 阅读(362) 评论(0) 推荐(0) 编辑
摘要: #-*-coding:utf-8-*- ''' ''' # join方法,,后面有用,爬之前就是用这个方法拼接的,虽然后来调用了方法自己拼接 # str,字典,列表,元组 s = 'bowen' s1 = '_'.join(s) print(s1) # 列表转换成字符串 join() # 字符串转换成列表 split() li = ['bowen1','bowen2','bowen3'] s... 阅读全文
posted @ 2019-01-01 15:17 sunnybowen 阅读(171) 评论(0) 推荐(0) 编辑
摘要: 这题其实是有难度的,要是不看答案,能把这个小需求实现吗。连这个都实现不了,还想做开发??? 阅读全文
posted @ 2018-12-31 00:11 sunnybowen 阅读(584) 评论(0) 推荐(0) 编辑
摘要: #-*-coding:utf-8-*- ''' 统计用户输入的字符串中有几个数字 ''' # numList = ['0','1','2','3','4','5','6','7','8','9'] s = input('请输入字符串:') count = 0 for i in s: if i in numList: count +=1 print(count) 阅读全文
posted @ 2018-12-30 23:52 sunnybowen 阅读(2452) 评论(0) 推荐(0) 编辑
摘要: #-*-coding:utf-8-*- ''' ''' # 返回二进制的位数 i = 1 a = 2 b = 3 print(i.bit_length()) print(a.bit_length()) print(b.bit_length()) 阅读全文
posted @ 2018-12-30 16:25 sunnybowen 阅读(3788) 评论(0) 推荐(0) 编辑
摘要: #-*-coding:utf-8-*- ''' ''' print(2>1 and 11 and 16 or 2<4 and 3<2) # True print(1 or 2) # 1 print(0 or 2) # 2 print(2 or 3) # 2 print(3 or 2) # 3 print(3 or 0) # 3 print(5 or 100 or 12 or 9) # 5 pr... 阅读全文
posted @ 2018-12-29 20:16 sunnybowen 阅读(141) 评论(0) 推荐(0) 编辑
摘要: 二、 三次登录程序优化 这是对昨天的那个while程序的优化。输入三次错误的。最后不管是输入Y还是N,都会弹出fuck you 阅读全文
posted @ 2018-12-29 19:12 sunnybowen 阅读(228) 评论(0) 推荐(0) 编辑
摘要: 1 安装,依次执行下面的命令 wget http://www.python.org/ftp/python/3.6.4/Python-3.6.4.tgz tar -xvzf Python-3.6.4.tgz cd Python-3.6.4 ./configure --with-ssl make sud 阅读全文
posted @ 2018-12-27 23:39 sunnybowen 阅读(1138) 评论(0) 推荐(0) 编辑
摘要: 方法二: 其实上面的程序是将字典按照传统方式拼接的,一般不用 阅读全文
posted @ 2018-12-25 23:47 sunnybowen 阅读(17618) 评论(0) 推荐(1) 编辑
摘要: import urllib.parse url = 'https://www.baidu.com/s?wd=董博文&ie=utf-8&tn=97931839_hao_pg' ''' quote url编码函数''' ret =urllib.parse.quote(url) print(ret) '''url 解码函数''' ret = urllib.parse.unquote(ret) ... 阅读全文
posted @ 2018-12-25 23:43 sunnybowen 阅读(905) 评论(0) 推荐(0) 编辑
摘要: 方法2: 直接保存 运行结果: 阅读全文
posted @ 2018-12-25 23:40 sunnybowen 阅读(369) 评论(0) 推荐(0) 编辑
摘要: import urllib.request url ='http://www.baidu.com' response = urllib.request.urlopen(url=url) #print(response) # 打印对象 #print(type(response)) '''获取返回的内容,read()得到的是二进制的,要将二进制转换为str型,需要decode()方法''' # ... 阅读全文
posted @ 2018-12-24 23:32 sunnybowen 阅读(334) 评论(0) 推荐(0) 编辑
摘要: # import方式导入包时就执行包文件了,如果多次导入同一个包,也执行一次,后面的不会执行。 from rdrsTool.RdrsRequsts import RdrsRequests from rdrsTool.RdrsDB import RdrsDB from rdrsTool import 阅读全文
posted @ 2018-12-18 21:44 sunnybowen 阅读(1238) 评论(0) 推荐(0) 编辑
摘要: 1 创建用户z1并且赋予所有数据库上的所有表的select权限,可以看到,user表中的select_priv是Y,而db表并没有记录。也就是说,对所有数据库都拥有相同权限的用户不需要记录db表。而仅需把user表中的select_priv改为Y即可。 2 、将z1上的权限改为只对test1数据库上 阅读全文
posted @ 2018-12-08 23:00 sunnybowen 阅读(207) 评论(0) 推荐(0) 编辑
摘要: 一 存储过程与if语句 二 存储过程与case语句 三 存储过程与while 存储过程其实类似于编程语言中的函数,mysql中也有函数,区别在于函数必须有返回值,而存储过程没有。存储过程的参数有in,out,inout类型,而函数的参数只能是in类型的。如有函数需要从其他类型的数据库迁移到mysql 阅读全文
posted @ 2018-12-08 16:54 sunnybowen 阅读(305) 评论(0) 推荐(0) 编辑
摘要: 这个时候,点击关闭按钮,窗体会消失,不像以前那样点没反应了。不要小看了AWT。可以用它做很多东西。尤其是客户端C/S架构的。虽然在B/S架构上AWT,Swing毫无用武之地,但是开发客户端软件,Java的AWT、Swing还是用得到的! implement重写时,可以右击generate来。 还有对 阅读全文
posted @ 2018-11-28 23:07 sunnybowen 阅读(279) 评论(0) 推荐(0) 编辑
摘要: 不使用布局管理器是不是更灵活一些呢?还有就是其实javaGUI确实用的少了。现在很多项目都是B/S架构的,通过浏览器,除非是写个小工具啥的可能会用到。 阅读全文
posted @ 2018-11-28 22:21 sunnybowen 阅读(504) 评论(0) 推荐(0) 编辑
摘要: package MYSQK.example01; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; /** * 卡片... 阅读全文
posted @ 2018-11-24 22:52 sunnybowen 阅读(383) 评论(0) 推荐(0) 编辑
摘要: package MYSQK.example01; import java.awt.*; /** * 网络包布局管理器 */ class Layout extends Frame{ public Layout(String title){ GridBagLayout layout = new GridBagLayout(); GridBa... 阅读全文
posted @ 2018-11-24 21:35 sunnybowen 阅读(219) 评论(0) 推荐(0) 编辑
摘要: package MYSQK.example01; import java.awt.*; public class example01 { public static void main(String[] args){ // 设置窗体名称 Frame f= new Frame("GridLayout"); // 设置窗体中的布局管理器,Grid... 阅读全文
posted @ 2018-11-24 18:30 sunnybowen 阅读(236) 评论(0) 推荐(0) 编辑
摘要: 1 简介 2 代码 3 运行结果 ,这个地方有个问题,为中文的时候没显示出来,这个自己解决一下!应该是字符编码设置的问题 阅读全文
posted @ 2018-11-23 22:37 sunnybowen 阅读(1485) 评论(0) 推荐(0) 编辑