首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
从键盘输入一些字符,逐个把它们写到指定的文件,直到输入一个@为止。请完善代码。 示例1: 请输入文件名: out.txt 请输入字符串: Python is open.@ 执行代码后,out.txt文件中内容为: Python is open. 示例2:
从键盘输入一些字符,逐个把它们写到指定的文件,直到输入一个@为止。请完善代码。 示例1: 请输入文件名: out.txt 请输入字符串: Python is open.@ 执行代码后,out.txt文件中内容为: Python is open. 示例2:
admin
2019-09-02
52
问题
从键盘输入一些字符,逐个把它们写到指定的文件,直到输入一个@为止。请完善代码。
示例1:
请输入文件名:
out.txt
请输入字符串:
Python
is
open.@
执行代码后,out.txt文件中内容为:
Python is open.
示例2:
请输入文件名:
out.txt
请输入字符串:
python@123
执行代码后,out.txt文件中内容为:
Python
filename=input(’’请输入文件名:\n’’)
fp=
①
ch=input(’’请输入字符串:\n’’)
while
②
if’@’in ch:
else:
fp.write(ch+’’’’)
③
fp.close()
选项
答案
filename=input(’’请输入文件名:\n’’) fp=open(filename,’’w’’) ch=input(’’请输入字符串:\n’’) while ch!=’@’: if’@’in ch: t=ch.find(’’@’’) fp.write(ch[0:t]) break else: fp.write(ch+’’’’) ch=input(’’’’) fp.close()
解析
转载请注明原文地址:https://jikaoti.com/ti/MD50FFFM
本试题收录于:
二级Python题库NCRE全国计算机二级分类
0
二级Python
NCRE全国计算机二级
相关试题推荐
1.在考生文件央下新建一个名为“图书管理”的项目文件。2.在项目中新建一个名为“图书”的数据库。3.将考生文件夹下的所有自由表添加到“图书”数据库中。4.在项目中建立查询book_qu,其功能是查询价格大于等于10的图书(bo
在考生文件夹下完成下列操作:为了查询不同歌手演唱的歌曲,请设计一个表单mform.scx,其界面如下图所示:表单控件名为formone,表单的标题为“歌曲查询”。表单左侧有一个标签控件Labelone,显示内容为“输入歌手姓名”,一个文本
在考生文件夹下完成如下操作:1.打开表单one,向其中添加一个组合框(Combol),并将其设置为下拉列表框。2.在表单one中,通过表单设计器中的属性窗口设置组合框的RowSource和RowSourceType属性,使组合框Comb
在考生文件夹下完成如下简单应用:1.打开表单MYFORM4一4,把表单(名称为Forml)标题改为“欢迎您”,将文本“欢迎您访问系统”(名称为Label1的标签)改为25号黑体。最后在表单上添加“关闭”(名称为Command1)命令按钮,单击此按
在视图设计器中有、而在查询设计器中没有的选项卡是
为便于在表单中连续掭加同种类型的多个控件,可先按下“表单控件”工具栏中的
下面描述中不属于数据库系统特点的是
一个栈的初始状态为空。现将元素1、2、3、4、5、A、B、C、D、E依次入栈,然后再依次出栈,则元素出栈的顺序是()。
在VisualFoxPro中,宏替换可以从变量中替换出()。
在数据流图中,带有箭头的线段表示的是()。
随机试题
某机构设立一个义工发展小组,其总目标是通过系统性的义工小组培训,建立一支稳定的义工团队。围绕这个总目标,社会工作者建立了相应的其他目标。其中,“协助组员了解自己参与义务工作的动机和目的”属于小组工作的()目标。
Airpollutionkilledaboutsevenmillionpeoplelastyear,makingittheworld’ssinglebiggestenvironmentalhealthrisk,theW
经产妇孕36周,右肩前位,胎膜已破,胎心消失,肛诊宫口开全,无先兆子宫破裂征象,最恰当的处理是下列何项
A.两总体均数相等B.差值的总体均数等于0C.两总体均数不等D.差值的总体均数不等于0E.样本总体均数与已知的总体均数相等成组设计两样本均数比较的t检验,其检验假设为()
代谢性酸中毒在没有发展到循环衰竭程度时,首选治疗应该是
适宜碱性溶液冲洗阴道的患者是
《统计法》对统计人员素质的基本要求包括()。
教师的知识结构包括()。
学习负担是客观存在的,没有负担,就没有学习质量而言,负担越重,学习成绩越好。()
试论蔡元培五育并举。
最新回复
(
0
)