笨方法系列
name=input("please input your name :")
age=input("please input your age:")
# print("you name is %s,you age is %d"%(name,age))
print(f"you name is {name},you age is {age}")
print("my age is {}".format(age))
记住 input默认输出的是字符串 当使用格式化输入时 %d%s一定要记住用int
from sys import argv
script,user_name = argv
prompt = '> '
print("Hi %s ,I'm the %s script." % (user_name,script))
print("I'd like to ask you a few questions.")
print("Do you like me %s?" % user_name)
likes = input(prompt)
print("Where do you live %s?" % user_name)
lives = input(prompt)
print("What kind computer do you have?")
computer = input(prompt)
print("""
Alright, so you said %s about liking me.
You live in %s. Not sure where what is.
And you have a %s computer.Nice.
""" %(likes,lives,computer))
跟之前那个做的ESRGAN有点像 argv在命令行预接受一个参数
python 路径 参数
from sys import argv
script,filename=argv
print(f"we are going to erase{filename}")
print("If you don't want that,hit CTRL-C(^C)")
print("If you do want that,hit RETURN")
input("?")
print("Open the file>>>>")
target=open(filename,"w")
print("Truncating the file")
target.truncate()
print("Now I'm going to ask you for three lines.")
line1=input("line1:")
line2=input("line2:")
line3=input("line3:")
print("I'm going to write these to the file")
target.write(line1)
target.write("\n")
target.write(line2)
target.write("\n")
target.write(line3)
target.write("\n")
print("And finally,we close it")
target.close()