使用scanf()函数 [英] USING OF scanf() functons

查看:132
本文介绍了使用scanf()函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用scanf打印出生日期..但有一些条件

1)使用1 scanf功能我们打印日期和月份和年份..

2当一个时间日期如10然后是attomatically - (symbel)将来到这里...接下来我将打印月然后也来 - (symbel)。

最后我希望出生日期如10 -06-1996





OUT PUT IN以下养殖

打印您的出生日期:: 10- 06-1996

您的出生日期:: 10-06-1996

解决方案

Scant不打印:它从用户读取一个值并将其转换为内部形式。



要输出日期,请使用print,而不是scanf。



我在最好的时候不是scanf的忠实粉丝,读取字符串通常更好,然后使用sscanf来解析它,因为它更容易调试,更好也用于错误报告。



但是对于日期而言,printf非常简单:

 printf(%02d-%02d-%04d,日,月,年); 


import os,urllib

Path = os.getcwd()

if os.path.exists(Engineering)!= True:

os.makedirs(工程)

os.chdir(工程)

错误=< html>< head>< title> Apache Tomcat / 7.0.16 - 错误报告< / title>

##第一学期开始数学##



def Engg( Chapter_Name,Chapter,Prasad_Modules):

如果os.path.exists(Mathematics-I /+ Chapter_Name)!= True:

os.makedirs(数学 - I /+ Chapter_Name)

for Module in range(1,int(Prasad_Modules)+1):

url =http://engg1a.nuz.rgukt。在/内容/ Semester1 /数学-I / M _ + STR(章)+。 + STR(模块)+/ M _ + STR(章)+。 + STR(模块)+ _ RM / M_ + str(章节)+。+ str(模块)+_ RM.pdf

打印网址

Page = urllib.urlopen(url).read( )

如果Page [0:62]!=错误:

File_N AME = 数学-I / + Chapter_Name + / + STR(模块)+。 + Chapter_Name +。pdf

file = open(File_Name,w)

file.write(页)

file.close ()

Engg(序列和系列,1,9)

Engg(微分方程,2,9)

Engg (多个变量的函数,3,10)

Engg(数值分析,4,8)



##结束第一学期和第二学期开始数学##


file:///home/student/Desktop/diy-birthday-card.jpg

生日快乐

by using scanf to print the Date of birth..but there are some condition
1)using 1 scanf fucntion we print the date and month and year..
2when a time date like 10 then attomatically -(symbel) will come here...next i will print month then also come the -(symbel).
at last i want date of birth like 10-06-1996


OUT PUT IN following farmed
print your date of birth::10-06-1996
your date of birth ::10-06-1996

解决方案

Scant does not print: it reads a value from the user and converts it to an internal form.

To output the date, use print, not scanf.

I'm not a big fan of scanf at the best of times, it's generally better to read a string, and then use sscanf to parse that, as it's a lot easier to debug, and better for error reporting as well.

But the printf for as date is pretty simple:

printf("%02d-%02d-%04d", day, month, year);


import os,urllib
Path=os.getcwd()
if os.path.exists("Engineering")!=True:
os.makedirs("Engineering")
os.chdir("Engineering")
Error="<html><head><title>Apache Tomcat/7.0.16 - Error report</title>"
## Starting of Semester 1 Mathematics ##

def Engg(Chapter_Name,Chapter,Prasad_Modules):
if os.path.exists("Mathematics-I/"+Chapter_Name)!=True:
os.makedirs("Mathematics-I/"+Chapter_Name)
for Module in range(1,int(Prasad_Modules)+1):
url="http://engg1a.nuz.rgukt.in/content/Semester1/Mathematics-I/M_"+str(Chapter)+"."+str(Module)+"/M_"+str(Chapter)+"."+str(Module)+"_RM/M_"+str(Chapter)+"."+str(Module)+"_RM.pdf"
print url
Page=urllib.urlopen(url).read()
if Page[0:62]!=Error:
File_Name="Mathematics-I/"+Chapter_Name+"/"+str(Module)+". "+Chapter_Name+".pdf"
file=open(File_Name,"w")
file.write(Page)
file.close()
Engg("Sequences & Series",1,9)
Engg("Differential Equations",2,9)
Engg("Functions of Several Variables",3,10)
Engg("Numerical Analysis",4,8)

## Ending of Semester 1 and Starting of Semester 2 Mathematics ##


file:///home/student/Desktop/diy-birthday-card.jpg
happy birthday


这篇关于使用scanf()函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆