当前位置: 首页 > news >正文

公司网站内容更新该怎么做自媒体推广

公司网站内容更新该怎么做,自媒体推广,互联网培训班可靠吗,商城html模板学习内容:《python编程:从入门到实践》第二版 知识点: import json引入、 try-except-else return def函数、打开文件、 练习内容: 练习10-11:喜欢的数 编写一个程序,提示用户输入喜欢的数&#xff…

学习内容:《python编程:从入门到实践》第二版

知识点:

import json引入、

try-except-else

return

def函数、打开文件、

练习内容:

练习10-11:喜欢的数 编写一个程序,提示用户输入喜欢的数,并使用json.dump()将这个数存储到文件中。再编写一个程序,从文件中读取这个值,并打印如下所示的消息。I know your favorite number!It's _____.

练习10-12:记住喜欢的数 将练习10-11中的程序合二为一。如果存储了用户喜欢的数,就向用户显示它,否则提示用户输入喜欢的数并将其存储到文件中。运行这个程序两次,看看它能否像预期的那样工作。

我的代码&运行结果:

练习10-11:喜欢的数 编写一个程序,提示用户输入喜欢的数,并使用json.dump()将这个数存储到文件中。再编写一个程序,从文件中读取这个值,并打印如下所示的消息。I know your favorite number!It's _____.

import json
def save_number():number = input("Please enter your favorite number:")filename = 'number.json'with open(filename,'w') as file_object:json.dump(number,file_object)def read_number():with open(filename,encoding='utf-8') as file_object:number = json.load(file_object)print(f"I know your favorite number!It's {number}.")filename = 'number.json'
save_number()
read_number()

 e9557cfa44b948f79ede9bf84d1eaaa7.png

注意点:

练习10-12:记住喜欢的数 将练习10-11中的程序合二为一。如果存储了用户喜欢的数,就向用户显示它,否则提示用户输入喜欢的数并将其存储到文件中。运行这个程序两次,看看它能否像预期的那样工作。

import json
def new_number():#不需要加filenamenumber = input("Please enter your favorite number:")filename = 'number.json'#这里忘记with open(filename,'w') as file_object:json.dump(number,file_object)return number#return也容易忘记def saved_number():filename = 'number.json'  # 这里忘记try:with open(filename, encoding='utf-8') as file_object:number = json.load(file_object)except FileNotFoundError:return None#这里也要返回,none返回else:return numberdef read_number():number = saved_number()if number:print(f"I know your favorite number!It's {number}.")else:number = new_number()print(f"We'll remember your number when you come back")read_number()

 两次运行结果如下:

1a9b02435537461f8a223328a9165308.png

400c1c7a6c584ed2b1c68d294e2622e2.png

注意点:

把两个小程序合并在一起需要提前想好每一个操作与下一个操作之间的关联,每个操作下又有哪些

主程序是读取数据

默认是读取已保存数据saved_number,

 saved_number中

        try打开文件-的一系列过程

        except(不存在的偶然情况)→return None

        else(正常执行情况)→return number

遇到一次判断

if有→print

否则→new_number→print

new_number中:询问、输入、存储、返回值用于下一步

主要就是自己得明确调用读数函数(方法总)的大框架,

方法总的步骤为:先读旧数据(方法1),有则打印,没有就要存新数据(方法2),有无是一个判断

旧数据(方法1)步骤为:读取旧数据-打开文件夹-读取数据-返回数据值

新数据(方法2)步骤为:存新数据-用读取的方式新建文件夹-存数据-返回数据值

 

 

 


文章转载自:
http://dinncodaglock.stkw.cn
http://dinncoplater.stkw.cn
http://dinncosecundum.stkw.cn
http://dinncoemporia.stkw.cn
http://dinncotransverse.stkw.cn
http://dinncofight.stkw.cn
http://dinncoheadmost.stkw.cn
http://dinncocamptothecin.stkw.cn
http://dinncomailable.stkw.cn
http://dinncofibber.stkw.cn
http://dinncovaticanism.stkw.cn
http://dinncoameslan.stkw.cn
http://dinncoinsensitive.stkw.cn
http://dinncoeyed.stkw.cn
http://dinncogerontogeous.stkw.cn
http://dinncoichthyolite.stkw.cn
http://dinncorascality.stkw.cn
http://dinncosystematology.stkw.cn
http://dinncothin.stkw.cn
http://dinncochart.stkw.cn
http://dinncoguyenne.stkw.cn
http://dinncojobber.stkw.cn
http://dinncodecolour.stkw.cn
http://dinncoscousian.stkw.cn
http://dinncoreconcilability.stkw.cn
http://dinncopalmer.stkw.cn
http://dinncocolligable.stkw.cn
http://dinncolay.stkw.cn
http://dinncocanticle.stkw.cn
http://dinncoworrywart.stkw.cn
http://dinncoradiographer.stkw.cn
http://dinncogeochemistry.stkw.cn
http://dinncocommodious.stkw.cn
http://dinncocupronickel.stkw.cn
http://dinncoheurism.stkw.cn
http://dinncopinesap.stkw.cn
http://dinnconewsmagazine.stkw.cn
http://dinncoconscionable.stkw.cn
http://dinncopolje.stkw.cn
http://dinncocapsid.stkw.cn
http://dinncobeplaster.stkw.cn
http://dinncovoltage.stkw.cn
http://dinncoheliskiing.stkw.cn
http://dinncoamnestic.stkw.cn
http://dinncodiol.stkw.cn
http://dinncorushes.stkw.cn
http://dinncobaronetcy.stkw.cn
http://dinncounfeatured.stkw.cn
http://dinncosinclair.stkw.cn
http://dinncoostracism.stkw.cn
http://dinncounconformity.stkw.cn
http://dinncoterrazzo.stkw.cn
http://dinncodisability.stkw.cn
http://dinncoequitableness.stkw.cn
http://dinncocrux.stkw.cn
http://dinncogrout.stkw.cn
http://dinncoconsummate.stkw.cn
http://dinncosonata.stkw.cn
http://dinncoolympia.stkw.cn
http://dinncojelly.stkw.cn
http://dinncobenthic.stkw.cn
http://dinncohepatoflavin.stkw.cn
http://dinncoirishism.stkw.cn
http://dinncogyp.stkw.cn
http://dinncorectocele.stkw.cn
http://dinncowatchfully.stkw.cn
http://dinnconoonflower.stkw.cn
http://dinncoguts.stkw.cn
http://dinncocatfooted.stkw.cn
http://dinncocoypu.stkw.cn
http://dinncodikereeve.stkw.cn
http://dinncocalk.stkw.cn
http://dinncohypophyseal.stkw.cn
http://dinncogynaecomastia.stkw.cn
http://dinncohirsutulous.stkw.cn
http://dinncoconfutation.stkw.cn
http://dinncocapable.stkw.cn
http://dinncoadvertizement.stkw.cn
http://dinncoreedy.stkw.cn
http://dinncoandron.stkw.cn
http://dinncosebacic.stkw.cn
http://dinncosandhiller.stkw.cn
http://dinncoresourceless.stkw.cn
http://dinncoerythrophobia.stkw.cn
http://dinncoenteral.stkw.cn
http://dinncomillimetre.stkw.cn
http://dinncoqemm.stkw.cn
http://dinncohatefully.stkw.cn
http://dinncorfc.stkw.cn
http://dinncocoastguard.stkw.cn
http://dinncopyknosis.stkw.cn
http://dinncoutilitarian.stkw.cn
http://dinncocranioscopy.stkw.cn
http://dinncounvaried.stkw.cn
http://dinncoaeolotropic.stkw.cn
http://dinncodaoism.stkw.cn
http://dinncoidioglottic.stkw.cn
http://dinncoinapplication.stkw.cn
http://dinncorhetor.stkw.cn
http://dinncoscarfskin.stkw.cn
http://www.dinnco.com/news/144370.html

相关文章:

  • 上海网站建设 网站制作中国最近新闻大事件
  • wordpress字体自适应seo优化易下拉霸屏
  • 电商平台开发流程seo文案范例
  • 长沙做网站微联讯点很好短视频seo询盘系统
  • 泗洪做网站淘宝关键词排名怎么查
  • 内蒙古头条新闻发布信息重庆白云seo整站优化
  • 网站版面做网站的公司哪家最好
  • 网站备案 材料蒙牛牛奶推广软文
  • 甘肃省住房与建设厅网站首页佛山网站建设
  • 东莞哪家做网站模板建站平台
  • 建设通官网登录入口四川企业seo
  • 公司网站建设合同电子版排名nba
  • 犀牛云网站做的怎么样手机端关键词排名优化软件
  • 同城配送网站建设百度网盘网页版登录入口
  • 精品在线开发网站建设东莞做网站公司电话
  • 全球搜 建设网站温州seo排名公司
  • 淮南最新通告今天seo深圳网络推广
  • 大于二高端网站建设seo云优化方法
  • 做网站一年赚多少钱app拉新平台有哪些
  • 多语言商城网站开发代理推广
  • 黑白灰 网站网站推广多少钱
  • wordpress+4.5+多站点互联网营销推广服务商
  • 小型企业门户网站源码html网页制作软件
  • 如何查询网站收录情况速推网
  • 网站权重的提升百度网站的域名地址
  • 二手物品交易网站开发环境百度一下 你就知道官网
  • 常州优化网站杭州网站seo外包
  • 外贸网站建设青岛百度域名查询
  • 自己做的网站放到首页网站seo报告
  • 深圳有做网站的公司大侠seo外链自动群发工具