博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Pycharm开发环境设置与熟悉。
阅读量:6501 次
发布时间:2019-06-24

本文共 3622 字,大约阅读时间需要 12 分钟。

练习基本输入输出:

print('你好,{}.'.format(name))

print(sys.argv)

 

库的使用方法:

import ...

from ... import ...

 

条件语句:

    if (abs(pos()))<1:

        break

 

循环语句:

for i in range(5):

while True:

 

函数定义:

def mygoto(x,y):

def drawjx(r):

 

综合练习:画一面五星红旗,将代码与运行截图发布博客交作业。

 

import turtledef mygoto(x, y):    turtle.up()    turtle.goto(x, y)    turtle.down()def drawF(x):    turtle.begin_fill()    for i in range (5):        turtle.forward(x)        turtle.right(144)    turtle.end_fill()turtle.setup=(600, 400, 0, 0)turtle.color("yellow")turtle.bgcolor('red')turtle.fillcolor("yellow")mygoto(-270, 120)drawF(120)for i in range(4):    x=1    if i in [0, 3]:        x=0    mygoto(-120+x*30,150-i*40)    turtle.left(15-i*15)    drawF(30)mygoto(0, 0)turtle.hideturtle()turtle.done()

 

字符串练习:

http://news.gzcc.cn/html/2017/xiaoyuanxinwen_1027/8443.html

取得校园新闻的编号

 

str = "http://news.gzcc.cn/html/2017/xiaoyuanxinwen_1027/8443.html"num = str.rstrip(".html").split("_")[1]print(num)

 

docs.python.org/3/library/turtle.html

产生python文档的网址

 

str1 = "https://docs.python.org/3.6/library/"str2 = ".html"str =str1+"turtle"+str2print(str)

 

http://news.gzcc.cn/html/xiaoyuanxinwen/4.html

产生校园新闻的一系列新闻页网址

 

for i in range(2,10):  str = "http://news.gzcc.cn/html/xiaoyuanxinwen/{}.html".format(i)  print(str)

 

练习字符串内建函数:strip,lstrip,rstrip,split,count,replace

用函数得到校园新闻编号

用函数统计一歌词(文章、小说)中单词出现的次数,替换标点符号为空格,用空格进行分词。

 

str = '''I'm hurting, baby, I'm broken downI need your loving, loving, I need it nowWhen I'm without youI'm something weakYou got me beggingBegging, I'm on my kneesI don't wanna be needing your loveI just wanna be deep in your loveAnd it's killing me when you're awayOoh, baby,'Cause I really don't care where you areI just wanna be there where you areAnd I gotta get one little tasteYour sugarYes, pleaseWon't you come and put it down on meI'm right here, 'cause I needLittle love and little sympathyYeah you show me good lovingMake it alrightNeed a little sweetness in my lifeYour sugarYes, pleaseWon't you come and put it down on meMy broken piecesYou pick them upDon't leave me hanging, hangingCome give me someWhen I'm without yaI'm so insecureYou are the one thingThe one thing, I'm living forI don't wanna be needing your loveI just wanna be deep in your loveAnd it's killing me when you're awayOoh, baby,'Cause I really don't care where you areI just wanna be there where you areAnd I gotta get one little tasteYour sugarYes, pleaseWon't you come and put it down on meI'm right here, 'cause I needLittle love and little sympathyYeah you show me good lovingMake it alrightNeed a little sweetness in my lifeYour Sugar! (Your sugar!)Yes, please (Yes, please)Won't you come and put it down on meYeahI want that red velvetI want that sugar sweetDon't let nobody touch itUnless that somebody's meI gotta be a manThere ain't no other way'Cause girl you're hotter than southern California BayI don't wanna play no gamesI don't gotta be afraidDon't give all that shy shitNo make up on, that's mySugarYes, pleaseWon't you come and put it down on me (down on me!)Oh, right here (right here),'Cause I need (I need)Little love and little sympathyYeah you show me good lovingMake it alrightNeed a little sweetness in my lifeYour sugar! (Sugar!)Yes, please (Yes, please)Won't you come and put it down on meYour sugarYes, pleaseWon't you come and put it down on meI'm right here, 'cause I needLittle love and little sympathyYeah you show me good lovingMake it alrightNeed a little sweetness in my lifeYour sugarYes, pleaseWon't you come and put it down on me(Down on me, down on me)'''print(str.count("sugar"))print(str.replace(","," "))

 

转载于:https://www.cnblogs.com/BOXczx/p/8619333.html

你可能感兴趣的文章
RAID简概
查看>>
起点没有选对,想找好的前端工作只能越找越累
查看>>
百度霸屏靠谱吗
查看>>
notepad++ 64位安装json插件JStool
查看>>
MySQL 索引
查看>>
python 代码审计-命令执行漏洞(自己编写的代码)
查看>>
UITableViewCell中的使用cell和cell.contentView的区别
查看>>
composer出现404错误
查看>>
Java : List中 根据map的某个key去重
查看>>
移动端车牌识别产品特点
查看>>
centos7安装配置 nginx
查看>>
高并发场景下的缓存+数据库双写不一致问题分析与解决方案
查看>>
docker 容器开发
查看>>
FTP 服务搭建与配置
查看>>
赠书福利丨Kubernetes权威指南第4版
查看>>
EJB技术,够重!够杂!
查看>>
ubuntu12.04--中文输入法ibus安装
查看>>
OSChina 娱乐弹弹弹——程序员的那点事,你还不知道吗?
查看>>
通过域名获取IP的方法
查看>>
前端那些事之javascript内存
查看>>