摘要: 创建一个文件,写入当前日期 import datetime now = datetime.datetime.now() with open('c.txt','w') as f f.write(str(now)) 1 with open('c.txt','r') as f: 2 text_4=f.re 阅读全文
posted @ 2019-12-06 15:14 九州天空城 阅读(227) 评论(0) 推荐(0) 编辑
摘要: 1. 定义一个字典,分别使用a、b、c、d作为字典的关键字,值为任意内容2. 为该字典增加一个元素‘c':'cake'后,将字典输出到屏幕 3. 取出字典中关键字为d的值 dic={"a":"area","b":"bike","c":"William"} dic['c']='cake' print( 阅读全文
posted @ 2019-12-06 14:58 九州天空城 阅读(250) 评论(0) 推荐(0) 编辑
摘要: 使用for语句输出1-100之间的所有偶数 for i in range(1,101): if i%2==0: print(i) 使用while语句输出1-100之间能够被3整除的数字 j=1 while j<100: if j%3 ==0: print(j) j+1 阅读全文
posted @ 2019-12-06 14:00 九州天空城 阅读(6972) 评论(0) 推荐(0) 编辑
摘要: 提示用户输入一个1-40之间的数字,使用if语句根据输入数字的大小进行判断,如果输入的数字在 num_user=input('输入一个1-40之间的整数:') num_int=int(num_user) if 1<=num_int<=10: print('数字再1到10之间') elif 11<=n 阅读全文
posted @ 2019-12-06 13:57 九州天空城 阅读(593) 评论(0) 推荐(0) 编辑
摘要: string1='123456789' print(len(string1)) # 使用len()计算字符串长度 if not len(string1) ==10: print('字符串的长度不为10') else: print("字符串的长度等于10") 使用if判断字符串的长度是否等于10,根据 阅读全文
posted @ 2019-12-06 13:53 九州天空城 阅读(1416) 评论(0) 推荐(0) 编辑
摘要: a="3432535541787" 1: print(a[::-1]) 2: b=list(a) b.reverse() print(''.join(b)) 3: c=len(a)-1 str_1=[] while(c>=0): str_1.append(a[c]) c -=1 print(''.j 阅读全文
posted @ 2019-12-05 10:49 九州天空城 阅读(15982) 评论(1) 推荐(0) 编辑
摘要: def digui(n): result = 1 if n == 2: result = 2 elif n 2: result = n digui(n 1) print(result) return result digui(4) 阅读全文
posted @ 2019-12-05 10:36 九州天空城 阅读(231) 评论(0) 推荐(0) 编辑
摘要: 1 def deDict(dict_o,value=None): 2 3 if type(dict_o) is dict and "william" in dict_o.keys(): 4 if dict_o['william']=value 5 dict_0=None 6 print(dict_o 阅读全文
posted @ 2019-12-05 10:32 九州天空城 阅读(1166) 评论(0) 推荐(0) 编辑
摘要: 安装MySQL8后用navicat连接时出现1251错误 解决办法 管理员打开cmd窗口 mysql -uroot -p登录mysql alter user root@localhost identified by'newpassword' password alter user root@loca 阅读全文
posted @ 2019-12-04 19:30 九州天空城 阅读(219) 评论(0) 推荐(0) 编辑
摘要: apache启动systemctl start httpd停止systemctl stop httpd重启systemctl restart httpdmysql启动systemctl start mysqld停止systemctl stop mysqld重启systemctl restart my 阅读全文
posted @ 2019-07-29 17:29 九州天空城 阅读(1462) 评论(0) 推荐(0) 编辑