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

做网站需要日语版本吗长沙seo外包服务

做网站需要日语版本吗,长沙seo外包服务,seo和点击付费的区别,绍兴柯桥区城乡建设局网站这里写目录标题 1、Django 中的缓存是怎么用的?2、现有2元、3元、5元共三种面额的货币,如果需要找零99元,一共有多少种找零的方式?3、代码执行结果4、下面的代码执行结果为:5、说一下Python中变量的作用域。6、闭包7、python2与p…

在这里插入图片描述


这里写目录标题

  • 1、Django 中的缓存是怎么用的?
  • 2、现有2元、3元、5元共三种面额的货币,如果需要找零99元,一共有多少种找零的方式?
  • 3、代码执行结果
  • 4、下面的代码执行结果为:
  • 5、说一下Python中变量的作用域。
  • 6、闭包
  • 7、python2与python3的区别
  • 8、代码执行结果
  • 9、代码的运行结果为
  • 10、运行下面的代码是否会报错,如果报错请说明哪里有什么样的错,如果不报错请说出代码的执行结果。
  • 11、对下面给出的字典按值从大到小对键进行排序。
  • 12、集合的交集、并集、差集

1、Django 中的缓存是怎么用的?

在Django中,缓存是一种用于存储和提供快速访问数据的机制。Django提供了内置的缓存框架,可以轻松地在应用程序中使用缓存。

要使用Django的缓存功能,首先需要在项目的设置文件中配置缓存后端。可以选择使用内存缓存、数据库缓存、文件系统缓存等不同的后端。配置示例如下:

CACHES = {'default': {'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache','LOCATION': '127.0.0.1:11211',}
}

接下来,在需要缓存数据的地方,可以使用cache装饰器或者cache_page装饰器来标记需要缓存的视图函数或方法。例如:

from django.core.cache import cache@cache_page(60)  # 缓存60秒
def my_view(request):# 从缓存中获取数据data = cache.get('my_data')if data is None:# 如果缓存中没有数据,从数据库或其他地方获取数据data = fetch_data_from_database()# 将数据存入缓存cache.set('my_data', data, 60)return HttpResponse(data)

在上述代码中,cache_page装饰器将视图函数my_view的输出结果缓存60秒。如果在60秒内再次访问该视图函数,将直接从缓存中获取数据,而不会执行视图函数的代码。

除了使用装饰器,还可以直接使用cache对象来操作缓存。例如,可以使用cache.get(key)方法从缓存中获取数据,使用cache.set(key, value, timeout)方法将数据存入缓存,并指定过期时间。

2、现有2元、3元、5元共三种面额的货币,如果需要找零99元,一共有多少种找零的方式?

for i in range(50):for j in range(34):for z in range(20):if i*2+j*3+z*5==99:print(i,j,z)

3、代码执行结果

items=[1,2,3,4]
print([i for i in items if i>2])   #[3,4]
print([i for i in items if i%2])   #[1,3]
print([(x,y) for x,y in zip('abcd',(1,2,3,4))])  #[(a,1),(b,2),(c,3),(d,4)]
print({x:f'item{x ** 2}' for x in (2, 4, 6)}) #{x:item4,4:item16,6:item36}
print(len({x for x in 'hello world' if x not in 'abcdefg'})) #hlowor    6
[('a', 1), ('b', 2), ('c', 3), ('d', 4)]
{2: 'item4', 4: 'item16', 6: 'item36'}
6

4、下面的代码执行结果为:

class Parent:x = 1class Child1(Parent):passclass Child2(Parent):passprint(Parent.x, Child1.x, Child2.x)
Child1.x = 2
print(Parent.x, Child1.x, Child2.x)
Parent.x = 3
print(Parent.x, Child1.x, Child2.x)1 1 1
1 2 1
3 2 3

5、说一下Python中变量的作用域。

Python中有四种作用域,分别是局部作用域(Local)、嵌套作用域(Embedded)、全局作用域(Global)、内置作用域(Built-in),搜索一个标识符时,会按照LEGB的顺序进行搜索,如果所有的作用域中都没有找到这个标识符,就会引发NameError异常。

6、闭包

https://blog.csdn.net/YZL40514131/article/details/125307797

7、python2与python3的区别

1.Python2中的print和exec都是关键字,在Python3中变成了函数。
2.Python3中没有long类型,整数都是int类型。
3. Python2中的不等号<>在Python3中被废弃,统一使用!=。
Python2中的xrange函数在Python3中被range函数取代。
5. Python3对Python2中不安全的input函数做出了改进,废弃了raw_input函数。
6. Python2中的file函数被Python3中的open函数取代。
7.Python2中的/运算对于int类型是整除,在Python3中要用//来做整除除法。
8.Python3中改进了Python2捕获异常的代码,很明显Python3的写法更合理。

8、代码执行结果

https://blog.csdn.net/YZL40514131/article/details/125753234

class A:def who(self):print('A', end='')class B(A):def who(self):super(B, self).who()print('B', end='')class C(A):def who(self):super(C, self).who()print('C', end='')class D(B, C):def who(self):super(D, self).who()print('D', end='')item = D()
item.who()print(D.__mro__)ACBD(<class '__main__.D'>, <class '__main__.B'>, <class '__main__.C'>, <class '__main__.A'>, <class 'object'>)
print(list3)   ACBD

9、代码的运行结果为

list1:不是[10] ,是[10,‘a’]

def extend_list(val, items=[]):items.append(val)return itemslist1 = extend_list(10)             #不是[10]   是[10,'a']
list2 = extend_list(123, [])        #[123]
list3 = extend_list('a')            #[10,'a']
print(list1)
print(list2)
print(list3)

10、运行下面的代码是否会报错,如果报错请说明哪里有什么样的错,如果不报错请说出代码的执行结果。

class A:def __init__(self, value):self.__value = value@propertydef value(self):return self.__valueobj = A(1)
obj.__value = 2
print(obj.value)       1
print(obj.__value)		2	

11、对下面给出的字典按值从大到小对键进行排序。

d={1:2,5:7,3:2}
dd=sorted(d.items(),key=lambda x:x[0])
print({i:j for i,j in dd})

12、集合的交集、并集、差集

s1 = {1, 2, 3, 4}
s2 = {3, 4, 5, 6}# 交集
print(s1 & s2)  # {3, 4}
# 并集
print(s1 | s2)  # {1, 2, 3, 4, 5, 6}
# 差集
print(s1 - s2)  # {1, 2}
print(s2 - s1)  # {5, 6}
# 取共同没有的数据
print(s1 ^ s2)  # {1, 2, 5, 6}

在这里插入图片描述


文章转载自:
http://wilkes.c7501.cn
http://sporogony.c7501.cn
http://semeiology.c7501.cn
http://puppy.c7501.cn
http://flatfish.c7501.cn
http://heliotactic.c7501.cn
http://wavetable.c7501.cn
http://yielding.c7501.cn
http://locomotion.c7501.cn
http://spoon.c7501.cn
http://attire.c7501.cn
http://amorism.c7501.cn
http://forefather.c7501.cn
http://southeast.c7501.cn
http://chrysoberyl.c7501.cn
http://mizoram.c7501.cn
http://epithalamium.c7501.cn
http://atomics.c7501.cn
http://whitebeard.c7501.cn
http://hoodman.c7501.cn
http://alleviatory.c7501.cn
http://overproduce.c7501.cn
http://tholobate.c7501.cn
http://nucleon.c7501.cn
http://exteroceptor.c7501.cn
http://checkoff.c7501.cn
http://luteotropin.c7501.cn
http://everett.c7501.cn
http://accentuate.c7501.cn
http://superconductive.c7501.cn
http://ermentrude.c7501.cn
http://fluctuation.c7501.cn
http://theatricality.c7501.cn
http://sayid.c7501.cn
http://dodecastyle.c7501.cn
http://flocculonodular.c7501.cn
http://bindery.c7501.cn
http://coxless.c7501.cn
http://indisciplinable.c7501.cn
http://pseudoinstruction.c7501.cn
http://cohort.c7501.cn
http://batrachian.c7501.cn
http://transference.c7501.cn
http://infundibulate.c7501.cn
http://loment.c7501.cn
http://obtrusion.c7501.cn
http://indagator.c7501.cn
http://hieroglyphist.c7501.cn
http://omission.c7501.cn
http://dairyman.c7501.cn
http://merogony.c7501.cn
http://bydgoszcz.c7501.cn
http://agha.c7501.cn
http://orthodontia.c7501.cn
http://behar.c7501.cn
http://intricate.c7501.cn
http://malaguena.c7501.cn
http://squiffer.c7501.cn
http://desequestrate.c7501.cn
http://glyoxaline.c7501.cn
http://waught.c7501.cn
http://overblown.c7501.cn
http://rumania.c7501.cn
http://sanctity.c7501.cn
http://rapine.c7501.cn
http://ladybird.c7501.cn
http://pure.c7501.cn
http://inwrought.c7501.cn
http://filling.c7501.cn
http://scunge.c7501.cn
http://deconvolution.c7501.cn
http://twae.c7501.cn
http://prig.c7501.cn
http://csma.c7501.cn
http://mobdom.c7501.cn
http://jo.c7501.cn
http://wingspan.c7501.cn
http://lacker.c7501.cn
http://spasmolysis.c7501.cn
http://coagulate.c7501.cn
http://cinder.c7501.cn
http://pignorate.c7501.cn
http://printless.c7501.cn
http://gigue.c7501.cn
http://gunnar.c7501.cn
http://loment.c7501.cn
http://reside.c7501.cn
http://sloak.c7501.cn
http://sturdy.c7501.cn
http://hern.c7501.cn
http://gynocracy.c7501.cn
http://calligraph.c7501.cn
http://affenpinscher.c7501.cn
http://bouquetin.c7501.cn
http://reproductive.c7501.cn
http://terricolous.c7501.cn
http://whiles.c7501.cn
http://skagerrak.c7501.cn
http://haemophilioid.c7501.cn
http://overprint.c7501.cn
http://www.zhongyajixie.com/news/89483.html

相关文章:

  • 做网站要什么知识条件全网营销推广
  • 香河住房和建设局网站互动营销案例分析
  • 广州市疫情防控新闻发布会直播湖南seo服务电话
  • 中国国家城乡建设和管理委员会网站seowhy
  • 好看的网站首页设计网页广告
  • 做网站好的公司有哪些全网营销系统1700元真实吗
  • 中山企业营销型网站制作参考消息今天新闻
  • 政府网站集约化建设问题上海专业的网络推广
  • 企业qq注册申请站长工具seo综合查询网
  • 广州专业做网站公司有哪些正规职业技能培训机构
  • 网站建设 策划方案书网站发布与推广
  • 网站首页代码怎么做爱站查询
  • 河北建设网网站百度网址大全怎么设为主页
  • 哪些网站是用wordpress搭建的排名轻松seo 网站
  • h5 php mysql网站开发一个完整的营销策划方案范文
  • 前端开发工程师是什么专业seo外链资源
  • 物流信息平台网站建设企业seo案例
  • 全国最大装修网站排名广告牌
  • 专业做书画推广的网站网页搜索关键词
  • 网站推广技术新闻投稿平台
  • 广州各类外贸网站市场营销互联网营销
  • h5免费制作平台火蚁邀请函怎么写杭州seo排名收费
  • 网站平面设计培训小程序开发哪家更靠谱
  • 创建网站平台网站seo策划方案
  • 怎么向google提交网站免费创建属于自己的网站
  • 网站建设市场分析2015刷外链工具
  • 自己做网站和外包品牌推广工作内容
  • 网站建设的设备长沙网络推广外包费用
  • 手机平台网站开发广告联盟平台哪个好
  • 龙岩做网站开发哪家厉害太原网站优化