Commit 354a0073 by BellCodeEditor

auto save

parent 1932fe6c
str1='本节课我们学习加密'
str2='用python进行'
str1=list(str1)
str1.insert(-4,str2)
str1=''.join(str1)
print(str1)
\ No newline at end of file
str1='bellcode'
print(str1[-4:])
\ No newline at end of file
import random
sum1=0
sum2=0
sum3=0
for i in range(3000):
x=random.randint(8,1000)
if x==8:
sum1+=1
if x==9:
sum2+=1
if x==10:
sum3+=1
print('8'+'有'+str(sum1)+'次','9'+'有'+str(sum2)+'次','10'+'有'+str(sum3)+'次')
\ No newline at end of file
text='Hello work'
for i in text:
print(i,end='')
print()
for i in range(len(text)):
print(text[i],end='')
\ No newline at end of file
...@@ -22,16 +22,30 @@ index = 0 ...@@ -22,16 +22,30 @@ index = 0
y = 400 y = 400
jumpState = "runing" jumpState = "runing"
t = 30 t = 30
bg_x = 0
road_x = 0 road_x = 0
obstacle = random.choice([bush, stone, cacti]) time=0
rect = obstacle.get_rect() # #obstacle = random.choice([bush, stone, cacti])
rect.x = 1000 # rect = obstacle.get_rect()
rect.y = 500 - rect.height # rect.x = 1000
# rect.y = 500 - rect.height
class Block(pygame.sprite.Sprite): class Block(pygame.sprite.Sprite):
def __init__(self,image1,image2,image3): def __init__(self,image1,image2,image3):
super().__init__() super().__init__()
self self.image = random.choice([image1,image2,image3])
self.rect=self.image.get_rect()
self.rect.x=1000
self.rect.y=500-self.rect.height
class Player(pygame.sprite.Sprite):
def __init__(self,image):
super().__init__()
self.image=image
self.rect=self.image.get_rect()
self.rect.x=150
self.rect.y=400
block_list=pygame.sprite.Group()
while True: while True:
for event in pygame.event.get(): for event in pygame.event.get():
if event.type == locals.QUIT: if event.type == locals.QUIT:
# 接收到退出事件后退出程序 # 接收到退出事件后退出程序
...@@ -43,19 +57,20 @@ while True: ...@@ -43,19 +57,20 @@ while True:
road_x-=8 road_x-=8
if road_x<-1000: if road_x<-1000:
road_x=0 road_x=0
if jumpState == "up": # 起跳状态 if gamesate=='True':
if t > 0: if jumpState == "up": # 起跳状态
y -= t if t > 0:
t -= 2 y -= t
else: t -= 2
jumpState = "down" else:
if jumpState == "down": # 降落状态 jumpState = "down"
if t <= 30: if jumpState == "down": # 降落状态
y += t if t <= 30:
t += 2 y += t
else: t += 2
jumpState = "runing" else:
t =30 jumpState = "runing"
t =30
# 悟空造型 # 悟空造型
wukong = hero[index] wukong = hero[index]
...@@ -63,19 +78,28 @@ while True: ...@@ -63,19 +78,28 @@ while True:
index += 1 index += 1
if index >= 5: if index >= 5:
index = 0 index = 0
# 将背景图画上去 # 将背景图画上去WWWWWAASDD
screen.blit(background, (0, 0)) # 远处背景 screen.blit(background, (0, 0)) # 远处背景DJDJ FGYJRNFJUJKRHYJGGYFDGYDB
screen.blit(road, (road_x, 500)) # 路 screen.blit(road, (road_x, 500)) # 路
screen.blit(wukong, (150, y)) # 悟空 screen.blit(wukong, (150, y)) # 悟空
time+=1
if rect.x <= 0-rect.width: # 障碍物消失 if time>=60:
# 创建障碍物对象 time=0
obstacle = random.choice([bush,stone,cacti]) n=random.randint(0,50)
rect = obstacle.get_rect() if n>20:
rect.x = 1000 obstacle=Block(bush,stone,cacti)
rect.y = 500 - rect.height block_list.add(obstacle)
rect.x -= 8 for sprite in block_list:
screen.blit(obstacle, (rect.x, rect.y)) sprite.rect.x -=8
screen.blit(sprite.image,( sprite.rect.x,sprite.rect.y))
if sprite.rect.x <= 0-obstacle.rect.width:
sprite.kill()
#obstacle = Block(bush,stone,cacti)
#rect = obstacle.get_rect()
#rect.x = 1000
#rect.y = 500 - rect.height
# rect.x -= 8
# screen.blit(obstacle, (rect.x, rect.y))
# 刷新画面 # 刷新画面
pygame.display.update() pygame.display.update()
FPS.tick(60) FPS.tick(60)
\ No newline at end of file
str1=['p','y','t','h','o','n']
str2='',join(str1)
print(str2)
\ No newline at end of file
import random
key1='周末一起去欢乐海岸'
text1='roswmzhx'
text1=list(text1)
for i in range(10):
a=random.randint(0,len(text1))
key1=list(key1)
key1.insert(a,text1[a])
print(key1)
key2=''.join(key1)
print(key2)
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment